wood burning stoves 2.0*
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


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "basic doubt" Watch "basic doubt" New topic
Author

basic doubt

Nijeesh Balan
Ranch Hand

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


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
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.
A GPuvathingal
Greenhorn

Joined: May 23, 2002
Posts: 10
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.


-
 
 
subject: basic doubt
 
Similar Threads
accesing document elements not having a form
help with developing a basic java program and algorithm for a program i am working on
Text field with #
about logic:iterate
Values in a text field