AJAX returning true in mid validation
This is the third time I have posted this and it is not showing...will try once more..
I have a form validation which I want to check if a few fields are empty and check if a number exists in the database before submitting. I must have everything out of order because most everything seems to work except that the form always submits even though I am trying to return false...
- $("#companyform").submit(function() {
$.ajaxSetup({ cache: false, asynch: false });
$.post("ajax_v2Functions.cfm", { coNum: $("#companyNumber").val() },
function(response) {
if(response != "") {
alert("That company number is already in use by " + response);
$("#companyNumber").focus();
return false;
}
return false;
} , "html");
if($("#companyname").val() == "") {
alert("The company name cannot be left blank.");
$("#companyname").focus();
return false;
}
if($("#companyNumber").val() == "") {
alert("The company number cannot be left blank.");
$("#companyNumber").focus();
return false;
}
});