I\'m using the validate plugin from http://bassistance.de/jquery-plugins/jquery-plugin-validation/
What i\'m trying to find is a way to make some of my form fields a
The following method to add a custom validator works fine, But the validation happens on keyup, So the error keeps on popping up while the user is typing the text.
return value.match(new RegExp(""));
The below method works fine for Alphabets and Spaces, Ideal for name fields.
jQuery.validator.addMethod("alphabetsAndSpacesOnly", function (value, element) { return this.optional(element) || /^[a-zA-Z\s]+$/.test(value); }); $("FieldId").rules("add", { alphabetsAndSpacesOnly: true, messages: { alphabetsAndSpacesOnly: "Please enter a valid name." } });