homepage Welcome to WebmasterWorld Guest from 50.17.21.7
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / HTML
Forum Library, Charter, Moderators: incrediBILL

HTML Forum

    
Form won't Submit
ENetArch




msg:4125617
 3:31 am on May 2, 2010 (gmt 0)

Hello Group,

Just wondering if others are experiencing this issue. provided below is a simple form, without a submit button. My understanding of HTML states that when ENTER is pressed, the form should submit by default. I tried this code in FF and IE and it does not submit by default as long as TWO (2) text fields are present.

Is anyone else experiencing this issue?
FF - 3.5.30729
IE - 8.0.6001.18702

simple HTML form ...

===========

<form>
<select name="testing">
<option value="1">testing</option>
</select>
<input type="text" name="text_01" value="">
<input type="text" name="text_02" value="">
</form>

===========

E Net Arch

 

ENetArch




msg:4125943
 5:34 am on May 3, 2010 (gmt 0)

In case no one response, a work around I built is provided here. Hopefully someone has a better solution.

==================

<script>
function keyPress (event, me)
{
switch (event.keyCode)
{
case 13:
{ me.form.submit(); }
break;
}
}
</script>

<form>
<select name="testing">
<option value="1">testing</option>
</select>
<input type="text" name="text_01" value="" onKeyPress="keyPress(event, this)">
<input type="text" name="text_02" value=""onKeyPress="keyPress(event, this)">
</form>

================

E Net Arch

Fotiman




msg:4126126
 2:26 pm on May 3, 2010 (gmt 0)

Your original assumption was incorrect. When the enter key is pressed within a text field, most browsers will submit the form using the FIRST submit button within the form. If you have no submit buttons... that's just weird.

The problem with your solution is:
1. It's not accessible to users with JavaScript disabled.
2. Have you tested this solution across browsers? I suspect it will not work on all browsers.

A better option might be to have a regular submit button, and then use JavaScript to hide the button (move it somewhere off screen). That way, the default browser behavior will still work and will remain accessible for users with JavaScript disabled.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / HTML
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved