It's not a secret anymore!
The moose likes HTML, CSS and JavaScript and the fly likes basic doubt Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "basic doubt" Watch "basic doubt" New topic

basic doubt

Nijeesh Balan
Ranch Hand

Joined: Oct 09, 2000
Posts: 116
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..

Thanks & Regards,<br />Nijeesh.
Charlie Sturman
Ranch Hand

Joined: Apr 04, 2002
Posts: 112
You must return false to stop the form from submitting
Yuriy Fuksenko
Ranch Hand

Joined: Feb 02, 2001
Posts: 413
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.
A GPuvathingal

Joined: May 23, 2002
Posts: 10
Hi Nijeesh,
Try this ....
function checkEnter(event){
return false;
<input type=text onKeyPress='return checkEnter(event)'>
<input type=submit>
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.

I agree. Here's the link:
subject: basic doubt
It's not a secret anymore!