I have a web application in which I have used jQuery validation engine for the client side validations.
This application maintains the record for which user have to enter some ID basically a number.
I maintain an array of all the serial number that users enter.
Now I want a validation on the form, that the value of ID enter by user should be already entered, means should not be in array.
egs: ids = {1,2,3,6,8}, Now next value of ID cannot be the values from the array ids. I want to write such rule in validation engine.
var validator = $("#formId").validate({
rules: {
uniqueId: <Rule to write here ???>,
},
messages: {
uniqueId: "Entered ID already exists",
},
});
Kindly help me out. Also if anyone has some link of tutorials or something from where I can learn all the possible validation rule implementations… that would be great.
Thanks in advance.
I’ve never worked with jQuery validation, but this should get you started.
First create the validation function
Then add it to the jquery validation rules:
And create a rule:
Here’s a blog post where I found much of this information, you may find it useful too