<script type="text/javascript" src="js/jquery.validate.js"></script>
<script type="text/javascript" src="js/jquery.metadata.js"></script>
<script type="text/javascript" src="js/jquery.validate.message_cn.js"></script>
<script type="text/javascript"> $().ready( function() { jQuery.validator.addMethod("noChinese", function(value, element) { var myReg = /^[a-zA-Z0-9_]{0,}$/; return this.optional(element) || (myReg.test(value)); }); }) </script> 并且在jquery.validate.message_cn.js里添加 noChinese: jQuery.format("不能含有中文或特殊字符"), 在页面应用:class="required noChinese"
时间: 2024-11-10 13:06:57