I have a form that is checking for valid fields after a user clicks submit. It looks like this:
<form class="form-horizontal" method="post" action="#" name="basic_validate" id="basic_validate" />
<div class="control-group">
<label class="control-label">Email Recipients</label>
<div class="controls">
<input type="text" name="emailreceipients" id="emailreceipients" />
</div>
</div>
<div class="form-actions">
<input type=submit value="Send" id="sendbtn" class="btn btn-primary" />
</div>
</form>
If an error is seen a class called: 'error' is added to the field.
How can I capture the form submission after all errors have been removed (e.g. user enters all data)
Here is the validation call that gets hit after form submission:
// Form Validation
$("#basic_validate").validate({
rules:{
required:{
required:true
},
emailreceipients:{
required:false
}
},
errorClass: "help-inline",
errorElement: "span",
highlight:function(element, errorClass, validClass) {
$(element).parents('.control-group').addClass('error');
},
unhighlight: function(element, errorClass, validClass) {
$(element).parents('.control-group').removeClass('error');
$(element).parents('.control-group').addClass('success');
}
});
I've tried something like this:
$("#sendbtn").click(function (e) {
e.preventDefault();
if ($("#basic_validate").children('.control-group').hasClass('error')) {
alert("Error Seen");
}
else {
// Process Form
}
});
Any idea how I can accomplish this?