<form name="myform" action="email.php" method="post">
The action parameter, as usual, specifies the server side script or page that will process the form data once it has been validated (in this instance the generic PHP form processor that I wrote and use with this site to process all of the forms).
The other change that you need to make is to the submit button to get it to call your validation routine which in turn will submit the form if it is valid rather than submitting the form directly. Your submit button might look like this:
<input type="submit" value="Submit this form"
onclick="formvalidation(myform);return false;" />
<input type=" button" name="submitit" value="Submit this form"
In this instance we don't need the return false on the end of the onclick as there is no subsequent processing that would be performed.
It almost doesn't matter what name you give to this button (if you name it) as in the rare event that you need to, you can reference it by whatever name you give it. I originally gave my button the name submit which worked quite happily with IE5, Netscape 4 and 6, and Opera but unfortunately is the one name that doesn't work with IE6. As a result my forms gave error messages whenever used with IE6 which one of the visitors to my site kindly pointed out so that I could fix the problem which was to change the name of the button to something other than submit.
Provided that your validation routine exits prior to executing this statement if any errors in the input are found (after displaying appropriate error messages of course) then your form will only be submitted once all of the validations are complete which will save you having to handle obviously incomplete information at a later stage in the process (after it is too late to ask your visitor to correct it). If you have several alternate validation options then you may end up with several spots in the code where you have completed validation and want to submit the form. You can insert the submit statement in each spot in the code where it is required.
This article written by Stephen Chapman, Felgall Pty Ltd.