On a page, I have several modals that all have a required email address.
The basic JS validation is as follows:
$("#resendValidation-form").validate({
// Rules for form validation
rules: {
email: {
required: true,
email: true
}
},
// Messages for form validation
messages: {
email: {
required: 'Please enter your email address',
email: 'Please enter a VALID email address'
}
},
errorPlacement: function (error, element) {
error.insertAfter(element.parent());
}
});
This validation is also required for #loginEmailAddress
and #resendEmailAddress
. Can I chain the ID's together somehow without having to have three instances of this code?
-- Update --
I am using the form in the JS, where a form is defined as follows in a Razor view:
@using (Html.BeginForm("ForgotPassword", "Account", FormMethod.Post, new { Email = Model, id = "forgotPassword-form" }))
You should be able to just do it like CSS selectors
$("#resendValidation-form, #loginEmailAddress, #resendEmailAddress").validate({});