0

I am using Chrome where pressing enter automatically submits a form.

I have two forms on different pages, and neither has a submit INPUT/BUTTON. Both forms have similar (text) inputs in them.

FORM 1 automatically submits its data when pressing enter. FORM 2 on the other hand doesn't. I have to find out why this happens. Is there a way to find out what submit handlers are there attached to the two forms?

myForm.get(0).onsubmit (using jQuery) returns null in both cases.

Or is there another way to debug this issue? (Chrome DevTools, etc)

Gabriel Petrovay
  • 20,476
  • 22
  • 97
  • 168
  • 2
    Visual Event might help. (it's a bookmarklet, just google it.) – Kevin B Jul 22 '13 at 19:37
  • is there a – omma2289 Jul 22 '13 at 19:43
  • None of the forms have a submit INPUT/BUTTON. Not even a button (without submit). – Gabriel Petrovay Jul 22 '13 at 19:45
  • How about posting the HTML of your forms? or better yet a fiddle that demonstrates the problem? – omma2289 Jul 22 '13 at 19:48
  • @KevinB Visual Event Chrome extensions looks great and also works great on other Web sites (like SO). It does not show my anything on mine though. +1 because it is a "good to know" tool. – Gabriel Petrovay Jul 22 '13 at 19:48
  • From your description it sounds like you had 2 forms __on the same page__ but only the first submits. That is apparently not the case? Do you not have access to the code for the form? How is the form added to your page? – Evan Davis Jul 22 '13 at 21:03
  • The forms are on two different pages. But I have just found the problem. It is just yes another browser specific issue. Writing the answer... – Gabriel Petrovay Jul 22 '13 at 21:05

2 Answers2

0

When you press enter it is always going to default to the first form.

if you wnat to submit the second form from script then you need:

document.forms[1].submit();

COBOLdinosaur
  • 284
  • 2
  • 6
0

I have researched the problem some more and the issue was around the FORMs having ONLY one text input.

FORM 1 has only one text input. FORM 2 has 2 text inputs. Therefore, in Chrome, FORM 1 will submit on Enter. I have already asked this question here.

So in my case, it is NOT a script that was adding submit handlers to the forms, but simply the browser specific implementation of forms. IE, for example does not behave like this.

PS: @KevinB It also makes sense why Visual Effects was not showing any handlers. Because there were none on the forms.

Community
  • 1
  • 1
Gabriel Petrovay
  • 20,476
  • 22
  • 97
  • 168