我已经下载了
jquery validation.js并使用它.我需要验证字母表中的字母.为此,我需要在validation.js中做
我的js是这样的,
categoryname: { required: true,minlength: 2 },messages: { categoryname: "Enter the category name",
解决方法
jQuery.validator.addMethod("alphanumericspecial",function(value,element) { return this.optional(element) || value == value.match(/^[-a-zA-Z0-9_ ]+$/); },"Only letters,Numbers & Space/underscore Allowed."); jQuery.validator.addMethod("alpha",element) { return this.optional(element) || value == value.match(/^[a-zA-Z]+$/); },"Only Characters Allowed."); jQuery.validator.addMethod("alphanumeric",element) { return this.optional(element) || value == value.match(/^[a-z0-9A-Z#]+$/); },"Only Characters,Numbers & Hash Allowed.");
你可以像这个兄弟一样轻松创建功能.