Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Enter key form submission

 
Abhi Singh
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


I have one text field and one button('Find') on my JSP page. If I press 'Enter' key my form is getting submitted without validation.
I have no submit button on my page. Although I have handled that problem by checking Enter key code. But I wnat to know the
root cause and its probably its solution
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65229
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Nothing to do with JSP. Moved to the HTML forum.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65229
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How do you have the validation hooked up? Can't help you with the scant info you have provided.
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You need to validate with onsubmit of the form, not onclick of a button.

Eric
 
Abhi Singh
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Eric Pascarello wrote:You need to validate with onsubmit of the form, not onclick of a button.

Eric


there is no submit button on my page.
I have used find button and it onclick is handled in js
$(.findbuttonclass).click(function(){
validateFind();
});
 
Abhi Singh
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bear Bibeault wrote:How do you have the validation hooked up? Can't help you with the scant info you have provided.

there is no submit button on my page.
I have used find button and it onclick is handled in js
$(.findbuttonclass).click(function(){
validateFind();
});

function validate(){
if(document.getElementById("account")==""){
return false;
}
}
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65229
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As Eric has already pointed out, a click handler is the worst possible place to handle validation. Us a submit handler established on the form.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic