goodle chrom alway submit when i enter keycode = 13

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
nv_thien
Forum Newbie
Posts: 4
Joined: Tue Apr 14, 2009 11:38 pm

goodle chrom alway submit when i enter keycode = 13

Post by nv_thien »

hi, anybody help me

i'm using JQuery.

i made a jquery dialog. then enter value on the Form. i have a function to validate data. but when i press key "Enter", it allway submit form to server. in IE and FF, it works fine

Thanks and best regards
Thien
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Re: goodle chrom alway submit when i enter keycode = 13

Post by pickle »

It's not a standard at all to submit a form when the user hits enter - that's a browser-by-browser specific behaviour. If you want it to always happen, you'll have to listen to the field for keycode 13 - enter.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
User avatar
php_east
Forum Contributor
Posts: 453
Joined: Sun Feb 22, 2009 1:31 pm
Location: Far Far East.

Re: goodle chrom alway submit when i enter keycode = 13

Post by php_east »

i know next to nothing about jquery, but for the form, supress the submit by using your own onsubmit().
User avatar
kaszu
Forum Regular
Posts: 749
Joined: Wed Jul 19, 2006 7:29 am

Re: goodle chrom alway submit when i enter keycode = 13

Post by kaszu »

@pickle Form submits on enter key press in all browsers if focus is on input and in form exists submit button.

I had similar issue with safari, problem was a typo. Check if your html is valid..
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Re: goodle chrom alway submit when i enter keycode = 13

Post by pickle »

kaszu wrote:@pickle Form submits on enter key press in all browsers if focus is on input and in form exists submit button.
That may be so, for all current browsers, but there's no guarantee the user the user has one of those browsers, or that all browsers will continue to provide this functionality in the future. My point was that just because it doesn't happen in a particular browser doesn't necessarily mean he's done something wrong.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
User avatar
php_east
Forum Contributor
Posts: 453
Joined: Sun Feb 22, 2009 1:31 pm
Location: Far Far East.

Re: goodle chrom alway submit when i enter keycode = 13

Post by php_east »

pickle wrote:That may be so, for all current browsers, but there's no guarantee the user the user has one of those browsers, or that all browsers will continue to provide this functionality in the future.
what ??? enter key is not guranteed to work ? has w3c gone mad ? it's absurd.
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Re: goodle chrom alway submit when i enter keycode = 13

Post by pickle »

I'm certainly not a w3c guru, but I've seen no specification that says a form must be submitted when enter is pressed. As ~kaszu stated, all current browsers do this, but that's simply for ease-of-use, not to meet any specification.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Re: goodle chrom alway submit when i enter keycode = 13

Post by Benjamin »

I'm actually looking for a way to PREVENT the enter key from submitting the form in a spare time project. I'm going to try to capture the keypress and make sure it does nothing.
User avatar
php_east
Forum Contributor
Posts: 453
Joined: Sun Feb 22, 2009 1:31 pm
Location: Far Far East.

Re: goodle chrom alway submit when i enter keycode = 13

Post by php_east »

pickle wrote:I'm certainly not a w3c guru, but I've seen no specification that says a form must be submitted when enter is pressed. As ~kaszu stated, all current browsers do this, but that's simply for ease-of-use, not to meet any specification.
well, yes, w3c doesn't exactly say use enter key. what i meant was that when it was said something like "browsers should submit form", it is translated in a normal way to mean when you pressed enter or click on the equivalent. it is a shortcut widely used by very many people. as is the tab key. in windows environment. i dunno, maybe i am missing something. but if browsers stop responding to enter key i'm sure many will have problems. that's all i'm saying.
Post Reply