Skip to content

Instantly share code, notes, and snippets.

jQuery.validator.addMethod("alphanumeric", function(value, element) {
return this.optional(element) || /^[A-Za-z0-9 _]*[A-Za-z0-9][A-Za-z0-9 _]*$/.test(value);
});
jQuery.validator.addMethod("letterwithspaces", function(value, element) {
return this.optional(element) || /^[a-zA-Z\s]+$/.test(value);
});
jQuery.validator.addMethod("imagetype", function(value, element) {
return this.optional(element) || /^.*\.(jpg|png|jpeg|gif)$/i.test(value);