Until now, I've used jQuery validation plugin with previously defined fields. Now I'm working with a dynamic form. Fields have their validation needs mapped by its classes (e.g. " required "), but I don't see how to customize the messages jQuery validate throws.
Java scriptready(function() { $("#basic-form"). validate(); }); This is based on the assumption that you have already added the required JavaScript files. Adding those lines of JavaScript will make sure that your form is properly validated and shows all the error messages.
valid()Returns: Boolean Description: Checks whether the selected form is valid or whether all selected elements are valid.
The jquery validate plugin requires a form element to function, so you should have your form fields (no matter how few) contained inside a form. You can tell the validation plugin not to operate on form submission, then manually validate the form when the correct submit button is clicked.
you can add your messages like so.
$.extend($.validator.messages, {
required: "your msg",
email: "your email msg",
digits: "your digits msg"
});
See setDefaults
$.validator.messages.required = "My new, default required message!";
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With