I want to run JavaScript user validation on some textbox entries.
The problem I'm having is that my form has the action of going to a new page within our site, and the onsubmit
attribute never runs the JavaScript function.
Is there a better solution, or one that works with the following code: Note: the JavaScript file is written correctly and works if you switch the action to checkRegistration()
.
It is merely an issue with running both action and JavaScript.
<form name="registerForm" action="validate.html" onsubmit="checkRegistration()" method="post">
<!-- Textboxes are here -->
<!-- And the submit button -->
</form>
This question is related to
javascript
html
forms
action
onsubmit
Try:
onsubmit="checkRegistration(event.preventDefault())"
Try
onsubmit="return checkRegistration()"
Source: Stackoverflow.com