JavaScript code returns false, but still the form is submittted

They are returning false (and breaking, which is actually unreachable code) but the results are never returned to parent validation function. Your validator, assuming it's bound to the form action, should look like:

function formvalidation(){
{
  if (!ZeroPhones())
    return false;
  if (!BlankPC())
    return false;

  //
  // keep checking for false and return false.
  //

  // default to return true
  return true;
}

So when the functions do in-fact return false, the false return is carried back up through to the bound function.


You need to have return false; in the function called by the onclick, in this case formvalidation.

Having some function called by the "root" function return false has no effect whatsoever. The return value is lost.


BlankPC() is called by formvalidation so false is returned into the method formvalidation().

Your formvalidation() is always falling off the end which is the same as returning true. If you want it to return false when one of your validations fails, it should be:

function formvalidation()
{
    retval = true;
    retval &= ZeroPhones();
    retval &= BlankPC();
    retval &= BlankSite();
    retval &= BlankSeats();
    retval &= phone_change();

    return retval;
} // End 

This can be optimized a bunch, but you can get the gist of it.