Validate Form First Then Do Ajax Call
Im using a jquery validation plugin to validate my form. But there are still some fields that need custom validation. The strange thing is. When submiting it checks my select box v
Solution 1:
Try this
$.validate({
onError : function() {
alert('Validation failed');
returnfalse;
}
});
Solution 2:
After playing with it i got it sort of working by doing this:
>>>> REMOVED (PLACEDONBOTTOM) event.preventDefault();
$( "#registration-form" ).submit(function( event ) {
var flag = $.validate();
if(!flag) {
//Check dropdownif(document.getElementById('foodassoonas').selectedIndex == 0)
{
$('#dateerrormsg').html('U heeft geen bezorgtijd aangegeven');
$("#foodassoonas").css({"border":"1px solid red"});
returnfalse;
}
var contactemail = $('#contactemail').val();
$.post(jssitebaseUrl+'/ajaxFile.php',{'contactemail':contactemail,'action':'checkOrderEmailId'}, function(output){
alert(output);
if(output == 'already' && contactpassword !=""){
$("#createUserError").addClass('errClass1 margin0');
$("#createUserError").html('not ok');
$("#createUserError").show();
returnfalse;
}elseif(output == 'gotopayment' || (output == 'already' && contactpassword =="")){
document.checkoutform.submit();
}
returnfalse;
});
return flag;
}
>>>> REMOVEDreturnfalse;
>>>> ADDED event.preventDefault();
});
only now the ajax is not fired :(
Post a Comment for "Validate Form First Then Do Ajax Call"