Internet Explorer form submit by enter key

Recently I was faced with an issue whereby when the user enters data into a single text input field form and submits via the enter key. No form fields would be passed to the processing page – this worked in all browsers but not Internet Explorer.

<form action="" method="POST">
    Field 1 <input name="field_1" type="text" />
    <input name="submit" type="submit" value="submit" />
</form>

The work around to this weird and wonderful bug is to add an additional disabled input field for IE, using IE conditional comment and hiding it from view using some CSS.

<form action="" method="POST">
    <!--[if IE]>
        <input type="text" style="display: none;" mce_style="display: none;" disabled="disabled" size="1" />
    <![endif]-->
    Field 1 <input name="field_1" type="text" />
    <input name="submit" type="submit" value="submit" />
</form>

This will now enable users to submit the form via the enter key in IE.

One thought on “Internet Explorer form submit by enter key”

Leave a Reply

Your email address will not be published. Required fields are marked *