Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

basic doubt

 
Nijeesh Balan
Ranch Hand
Posts: 116
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Charlie Sturman
Ranch Hand
Posts: 112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You must return false to stop the form from submitting
 
Yuriy Fuksenko
Ranch Hand
Posts: 413
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic