jquery实时监听input标签数字值的变化

xiaoxiao2021-02-28  83

要实现个小功能,input输入的类型是数字,并且不能超过int的最大值,写js进行校验

<input  id="test" οnkeyup="this.value=this.value.replace(/\D/g,'')" onafterpaste="this.value=this.value.replace(/\D/g,'')"/>

<script type="text/javascript">

 $(function(){

      $("#test").bind('input porpertychange',function(){

         if($("#test").val()>2147483647){                 alertMsg.error("值过大!");                 $("#test").val('');                 return;             }

    })

});

</script>

转载请注明原文地址: https://www.6miu.com/read-32395.html

最新回复(0)