Jump to content

Canceling Form Submissions


Recommended Posts

It is usually called from the 'onsubmit' of the form not 'onclick' of submit button as someone could submit by pressing the 'Enter' button, and so bypass the 'onclick' event.<form onsubmit="return valdatethis();" action="whateverpage.php" method="post">return will cause the function to run but wait for return value of 'true' to proceed, or 'false' to not proceed because data is not valid.function valdatethis(){var isvalid=true;//run code to validate codeif(....){isvalid=false;}if(....) { isvalid=false; }//if any fails the validation code in the if conditions above, the value for varible 'isvalid' will be set to false, else it will remain as true.//now all you have to do is return this varible valuereturn isvalid;}more detailed example shown here, slightly different but does the same thing.http://www.w3schools.com/js/js_form_validation.asp

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...