Welcome to WebmasterWorld Guest from 54.166.152.121

Forum Moderators: incrediBILL

Message Too Old, No Replies

Form won't Submit

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

5+ Year Member



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
5:34 am on May 3, 2010 (gmt 0)

5+ Year Member



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
2:26 pm on May 3, 2010 (gmt 0)

WebmasterWorld Senior Member fotiman is a WebmasterWorld Top Contributor of All Time 5+ Year Member Top Contributors Of The Month



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.
 

Featured Threads

Hot Threads This Week

Hot Threads This Month