Stop PHP execution after alert

Prevent the form’s submission if your condition isn’t met.

function formIsValid(form){
  // do your checks
  // and return true / false accordingly
}

$("form").on("submit", function(e){
  if(!formIsValid(this)){
    alert("Incorrect");
    e.preventDefault();
  }
});