[jQuery] [validate] Allowing letters only in a text input?
Hi,
I'm using the jQuery Validate plugin with success in it's basic form. I'm
looking to require ONLY letters in a field and I see that it's possible (I
think) using the code in the additional-methods.js file which is included in
the download package.
The code is as follows:
jQuery.validator.addMethod("lettersonly", function(value, element) {
return this.optional(element) || /^[a-z]+$/i.test(value);
}, "Letters only please");
My problem is that I'm not sure where to place the above code so that I can
require only letters in one of my fields?
Here is my current code:
$("#submit").validate({
errorPlacement: function(error, element) {
error.insertBefore(element);
},
rules: {
name: "required",
email: {
required: true,
email: true
}
},
messages: {
name: "Please enter your name",
email: {
required: "Please enter your email",
email: "Please enter a valid email address"
}
}
});
Thanks
--
View this message in context: http://www.nabble.com/-validate--Allowing-letters-only-in-a-text-input--tp20752566s27240p20752566.html
Sent from the jQuery General Discussion mailing list archive at Nabble.com.