首页 > Web开发 > 详细

js input 只能输入数字

时间:2019-05-13 16:31:10      阅读:78      评论:0      收藏:0      [点我收藏+]

HTML网页上这么写

<input type="text" style="ime-mode:disabled;" onpaste="return false;" onkeypress="keyPress()" />

 

function keyPress() {
var keycode = event.keyCode;
if ((keycode >= 48) && (keycode <= 57)) {
event.returnValue = true;
} else {
event.returnValue = false;
}
};

  

js input 只能输入数字

原文:https://www.cnblogs.com/yachao1120/p/10857171.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!