Say I have the following validation (using jQuery validation plugin) set up,
var validator = $("#name_change_form").validate({
rules: {
first_name: {
required: true,
regex: true
},
last_name: {
required: true,
regex: true
}
},
message: {
first_name: "Please enter your first name",
last_name: "Please enter your last name"
},
success: function(label) {
// display success
},
errorPlacement: function(error, element) {
// diplay error
}
});
Given the variable validator, is there a way to figure out that it’s associated with form whose id = “name_change_form”?
The
<form>element associated with the validator is available through its undocumentedcurrentFormproperty:Be careful though: again, this property is undocumented, so it might not exist anymore in future versions of the plugin.