[Logo]
Forums Register Login
basic doubt
Hi,
I have a form with two text boxes and a submit button. I am checking for some validations in onBlur of the text fields.
Now the problem is.. On invalid data, when i hit enter key the form gets submitted eventhough the error message pops up.
Plz clarify..
Cheers,
Nijeesh.
You must return false to stop the form from submitting
Hi,
in IE form sometimes get submited when you hit enter on text field.
If this is what happend in your case, you need to define onSubmit event handler for your form, define some variable, and check it status in onSubmit. Handler for your submit button should set this variable so, that submission will be allowed.
Hi Nijeesh,
Try this ....
<script>
function checkEnter(event){
if(event.keyCode==13){
return false;
}
}
</script>
<form>
<input type=text onKeyPress='return checkEnter(event)'>
<input type=submit>
</form>
Now the form wil not submit if the user hits on Enter key.....He will have to hit on Submit key to submit the form.
Wink, wink, nudge, nudge, say no more ... https://richsoil.com/cards



All times above are in ranch (not your local) time.
The current ranch time is
Oct 23, 2017 11:50:32.