While working on a ColdFusion application, I noticed that the login form was not submitted when enter was pressed in Internet Explorer. Other browsers, Firefox and Chrome specifically, did not have this issue. There are many methods used to fix this error if you Google it, but I found that the simplest solutions are usually the best. No javascript, no funky CSS to hide fields, yada, yada, yada.
The Situation
This app had a form with a single text field and a submit button. The form submitted back to its own page were the logic executed if form.submit (the submit button itself) came back with the form variables collection.
When you pressed the enter button, IE did not send the input type=submit field back with the form vars and the form logic did not execute. The page appeared to refresh and you started over again.
The Solution
All that was necessary was to add a hidden input field that the form logic used instead.
<input type="hidden" name="login" value="loginSubmit" />
If form.login and form.login = ‘loginSubmit’, the form logic executes and the user is logged in.
So, from now on, I am not going to rely on the input submit button to check for form submission. Call me crazy, but I think IE has the right idea here; the input submit should not be part of the form variables collection.
If this post helped you out, please consider donating to help pay the hosting fees. 100% of the donations go to the web host.
No related posts.


Twitter
About
6 Comments
I’ve seen situations where a form would not submit if there was on present submit button; but, I’m surprised that it didn’t submit if you actually had a submit button. Funky!
@Ben
Right, it was weird. Specifically, the user was entering their credentials (just email in this case for tracking) and hitting enter while the cursor was still in the text box. No dice with IE.
FYI: A google search reveals this is fairly well discussed.
And, actually, IE does not have right idea. [Many would say is hasn't even a clue.] …because if you have *more than one* input field, IE will process the form just fine via the ENTER key.
After creating many forms I just recently discovered this aberration when I created my first form with only one input field (other than the ‘submit’).
Bon appetit
@CalmQuiet
The post says that the logic on the page was looking for the form.submit which wasn’t being sent by IE. The point is to not rely on the submit button value being sent when enter is used instead of the submit button.
Thanks for your thoughts.
It sure is a bug from IE. Companies like mozilla,opera,google even apple treats submit forms in the same established rules. i don't know why microsoft allows such failures in their software.
I realize that when you have a submit button with a display:block style explorer neither submit the form.
Sorry 4 my poor englizh