Greetings, I have an "onsubmit" event that calls a form validation function... if everything is ok --> submit our form and move to the action page... but if a field is missing for example, how can i break and exit the function ?

i mean if i use :

if ( n == "" )
  alert("missing...");
  return; // or exit

It just doesn't exit the function... no it continues to submit the form and move to the action page... ( i can create a button instead of a submit button... but i don't want this... ) so ?

    The function called by onsubmit needs to return false when you don't want the form to submit by itself after the function completes. (Or you can add ";return false;" after the function call in the onsubmit attribute's value.)

      Write a Reply...