[jQuery] use an external js file for validation of many forms
I want to use an external js file for validation of many forms - all
of which have items in common, like start_date. I want it to be re-
usable from application to application.
Using the groups I have found that I can do this by having something
like
[code]
$(".sharedClassName).each.function() {
$(this).validate({
rules: {
sampling_date: {
required: true
, date: true
}
},
messages: {
sampling_date: "Please enter the date you collected your sample
in the format dd/mm/yyyy."
}
});
});
[/code]
BUT I also then want to create validations separately per form using
the rules.add format but I can't seem to make it work. Any ideas where
I am wrong?
[code]
$("input[name^='occurrencer']").rules("add", {
required:true,
messages: {
required: "You must enter a name"
}
});
[/code]
Thanks
K