• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

weird html problem

lozina

Lifer
I've got an html page i am trying to debug which has a simple file input form field, like this:

<input type="file" id="theFile" name="theFile">

no special events or anything attached to it

when the page loads if I focus on the text field for this file input to get the cursor blinking inside and press ENTER, it submits the whole page! what's even stranger is if I put just one space in there before pressing ENTER, it does not try to submit the page.

any clue at all why when I focus into a file form field and witohut typign anything, just press ENTER, it submits the page?

Again, no events attached to this form field, and there is no default submit type in the form, the only way to submit should be from a button which calls a function, and the alert I have in there is NOT being triggered!
 
yeah I think the file input field does that by default. Hitting Enter means you are submitting the form. You could put in some javascript that switches the focus to the browse button as soon as you click in there. That way when you focus the field, then hit Enter, you get your browse dialog box.
 
i've noticed this before with forms, but i've never bothered to figure out what changes the behavior of the enter button.

i have a form that for some odd reason refreshes when you hit the enter button in IE. it doesn't submit, just refreshes.
 
I believe this is standard behavior on certain browsers - when you push enter in a text box inside of a form, the form submits. To fix it, you typically need to catch the onkeypress event for the enter button and do something else with it.
 
Back
Top