I am wanting 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 here -->
<!-- and submit button -->
</form>
Try
You should stop submit procedure by returning false on onsubmit callback.
UPDATE:
here you have fully working example, form will submit only when you write google into input, otherwise it will return error: