我已经下载了
jquery validation.js并使用它.我需要验证字母表中的字母.为此,我需要在validation.js中做
@H_301_2@我的js是这样的,
categoryname: { required: true,minlength: 2 },messages: { categoryname: "Enter the category name",@H_301_2@上面的代码询问必填字段,如果字段为空,则会显示以下消息.在这里我需要验证只有字母表…….
解决方法
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.");@H_301_2@你可以像这个兄弟一样轻松创建功能.