| Author |
Enter key form submission
|
Abhi Singh
Greenhorn
Joined: Feb 02, 2010
Posts: 13
|
|
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
Joined: Jan 10, 2002
Posts: 56201
|
|
|
Nothing to do with JSP. Moved to the HTML forum.
|
[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56201
|
|
|
How do you have the validation hooked up? Can't help you with the scant info you have provided.
|
 |
Eric Pascarello
author
Rancher
Joined: Nov 08, 2001
Posts: 15357
|
|
You need to validate with onsubmit of the form, not onclick of a button.
Eric
|
 |
Abhi Singh
Greenhorn
Joined: Feb 02, 2010
Posts: 13
|
|
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
Joined: Feb 02, 2010
Posts: 13
|
|
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
Joined: Jan 10, 2002
Posts: 56201
|
|
|
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.
|
 |
 |
|
|
subject: Enter key form submission
|
|
|