Your form is submitting. In real life you may or may not want that. And in real life, unless you restrict access to the page to users with javascript enabled, the script won't run and the form will submit anyway.
That said, get rid of the onclick event here:
Code:
<input type="submit" value="validate" onclick="return validate(this.form)" />
Change it slightly and make it the form's onsubmit event:
Code:
<form id="form1" name="form1" class="bookingformtext" onsubmit="validate(this);return false;">
Now, it will never submit as long as javascript is enabled, a good method for testing the rest of the code. If you were to use:
Code:
<form id="form1" name="form1" class="bookingformtext" onsubmit="return validate(this);">
If the function validate() returns false, the form will not submit. Any other return value or no return value, the form will submit. If you want to use this method, look to your validate() function to see what it returns under the various circumstances it may encounter and ensure that the correct value (basically true or false) for your desired result as to whether the form should submit or not is returned by the validate() function under each of these possible circumstances.
Oh, and get rid of:
Code:
document.write (form1.q1.value)
!!
Bookmarks