日期:2014-05-16 浏览次数:20540 次
<script type="text/javascript" src="../JS/jquery-min-lastest.js"></script> <script type="text/javascript" src="../JS/jquery.validate.min.js"></script> <script type="text/javascript"> $().ready(function() { $("#form1").validate({ rules: { txtGRMS: { required: true, minlength: 5 } }, messages: { txtGRMS: { required: "不能为空!", minlength: jQuery.format("最少{0}个字符") } } }); }); </script> </head>
<html> <head> <script type="text/javascript"> function inputInt(el){ var format = /^[1-9]\d*$/; var str = ""; var value = el.value.replace(/[^\x00-\xff]/g,"**"); var len = value.length; if(value.length > 0){ for(var i=0;i<len;i++){ if(format.test(el.value.substring(0,i+1))){ str = el.value.substring(0,i+1); }else{ el.value = el.value.substring(0,i);; break; } } } } </script> </head> <body> <input type="text" onpropertychange="inputInt(this)" /> </body> </html>