The quick and dirty way:
Change <input type="submit"> to <input type="button">.
So long as it is a submit button, then it will submit the <form>!
***********
Better way. Get rid of the onclick on the submit button completely.
Change the <form> to:
<form name="regpage" action="reg.php" method="post"
onsubmit="return validate(this);">
Change your JS to:
Code:
function validate(form)
{
if ( form.usrNm.value==""
|| form.passWrd.value==""
|| form.cnfrmPsswrd.value==""
|| forme.state.value==""
|| form.zip.value ==""
) {
alert("You must fill out ALL required fields!");
return false;
}
return true;
}
But having said all the above...
WHy bother? That validation is essentially useless.
If the user enters a SINGLE SPACE (or any other character...or any other completely illogical value) for each field, it will pass validation.
If you are going to validate, then *REALLY* validate. Don't both with virtually useless code.
There are literally HUNDREDS (if not thousands) of posts in this very forum relating to form validation. Go look around and find some *good* validation.
p.s.: And I hope you are *ALSO* validating the <form> on your PHP page! Obviously form validation in JavaScript is useless if somebody turns off JavaScript. Or if a hacker hits your site without even using your code.