I have a form that Im validating with jQuery validate pluging.
This is my jQuery code for validating:
$('#authForm').validate({
rules: {
Email: {
required: true,
email: true
},
Password: {
required: true
},
PasswordAgain: {
equalTo: "#Password"
},
Name: {
required: true
}
},
errorClass: "invalid",
errorPlacement: function(error, element) { }
});
I have added an errorClass that I need to append to a parent div, not to the input field:
The HTML structure of one of the fields are like this:
<div class="form-group form-group-custom ">
<label>Email Address</label>
<input name="Email" type="text" class="form-control invalid" value="[email protected]" aria-required="true" aria-describedby="Email-error" aria-invalid="true">
</div>
And if you notice the "invalid" class has been appended to the input element that actually is correct, but I need to append it to my <div class="form-group form-group-custom"> and also remove it when the validation is ok.