META-INF.web.lib.js.bee.bee.validate.method.js Maven / Gradle / Ivy
(function(b){b.validator.addMethod("alphanumeric",function(d,a){return this.optional(a)||/^\w+$/i.test(d)},"Letters, numbers or underscores only please");b.validator.addMethod("lettersonly",function(d,a){return this.optional(a)||/^[a-z]+$/i.test(d)},"Letters only please");b.validator.addMethod("phone",function(a,d){a=a.replace(/\s+/g,"");return this.optional(d)||a.match(/^[0-9 \(\)]{7,30}$/)},"Please specify a valid phone number");b.validator.addMethod("postcode",function(a,d){a=a.replace(/\s+/g,"");return this.optional(d)||a.match(/^[0-9 A-Za-z]{5,20}$/)},"Please specify a valid postcode");b.validator.addMethod("date",function(a,d){a=a.replace(/\s+/g,"");return this.optional(d)||a.match(/^\d{4}[\/-]\d{1,2}[\/-]\d{1,2}$/)});b.validator.addClassRules({date:{date:false},alphanumeric:{alphanumeric:true},lettersonly:{lettersonly:true},phone:{phone:true},postcode:{postcode:true}});b.validator.setDefaults({errorElement:"span"});b.validator.autoCreateRanges=true})(jQuery);