JavaScript Not Submitting Form

polkjhydvrg

New Member
I've spent the last hour or so trawling through here and Google without success. I have a form that I want to submit via POST. The javascript runs and validates fine, it even 'submits' the form. But when it does, it just reloads the page. No POST headers are sent (confirmed using Firebug in Firefox). It's as though it simply reloads the page rather than submitting it.This form is embedded in the addUser.php page.\[code\]<form action="addUser.php" method="post" name="NewUser"><div data-role="field-contain"> <label label-for="EmpID" class="ui-hidden-accessible">Enter Employee ID</label> <input name="EmpID" id="EmpID" placeholder="Employee ID" value="" autocomplete="off" title="Enter Employee ID" type="number" required autofocus> <label label-for="UserName" class="ui-hidden-accessible">Enter username</label> <input name="UserName" id="UserName" placeholder="Username" value="" autocomplete="off" title="Enter the new username" required> <p> <label label-for="NewPass1" class="ui-hidden-accessible">Enter Your Current Password</label> <input name="NewPass1" id="NewPass1" placeholder="New Password" value="" type="password" autocomplete="off" title="Must be at least 8 characters, with numbers and upper and lower case letters." required> </p> <p> <label label-for="NewPass2" class="ui-hidden-accessible">Enter Your Current Password</label> <input name="NewPass2" id="NewPass2" placeholder="Verify Password" value="" type="password" autocomplete="off" title="Re-enter your chosen new password." required> </p></div><button type="button" name="submitButton" value="http://stackoverflow.com/questions/15515639/submitButton" data-theme="d" data-inline="true" data-icon="check" data-iconpos="left" onclick="validateForm ()"> Add User</button>\[/code\]And here is the Javascript:\[code\]function validateForm(){ var reason = ""; reason += validateEmpID(); reason += validateUserName(); reason += validateNewPassword(); if (reason != "") { alert("There are some errors with the data you entered:\n" + reason); return false; } else { document.NewUser.submit(); }}\[/code\]I have tried various different methods of calling submit, all with the same result. Any help greatly appreciated. ThanksGareth
 
Back
Top