My form onSubmit is calling:
onsubmit="validate(this); return false;"
validate() is as follows:
function validate(obj) {
$.ajax({
url : "ajax/validate_check.php",
type : "POST",
data : $("#" + obj.id).serialize(),
success : function(data) {
$('#' + obj.id + ' :input.form_errors').removeClass('form_errors')
data = $.parseJSON(data);
if(data['error_count'] >= 1) {
$.each(data, function(i, item) {
$('#' + i).addClass('form_errors');
});
} else {
$('#' + obj.id).submit();
}
}
});
}
When I have 0 errors it's trying to submit the form but I'm getting an infinite loop. I realize it's happening because my onSubmit calls the function again. How do I actually submit the form when I'm ready? What is the proper way to approach this?