<html>
<head>
<script type="text/javascript" src="/jquery/jquery.js"></script>
<script type="text/javascript">
var notNumber = /[^0-9]/;
$(".checkNum").live("input",function(){
var self = $(this);
val = self.val();
if(notNumber.test(val)){
self.val(val.replace(/[^0-9]/g,""));
}
});
</script>
</head>
<body>
<input class = "checkNum" />
</body>
</html>
JS实现Input文本框只可以输入数字
最新推荐文章于 2024-07-03 11:46:28 发布