Submitting a form by pressing enter without a submit button

Update 2022: Use this instead

<input type="submit" hidden />

Notice – Outdated answer
Please do not use position: absolute in the year 2021+. It’s recommended to use the hidden attribute instead. Otherwise, look down below and pick a better, more modern, answer.

Try:

<input type="submit" style="position: absolute; left: -9999px"/>

That will push the button waaay to the left, out of the screen. The nice thing with this is, you’d get graceful degradation when CSS is disabled.

Update – Workaround for IE7

As suggested by Bryan Downing + with tabindex to prevent tab reach this button (by Ates Goral):

<input type="submit" 
       style="position: absolute; left: -9999px; width: 1px; height: 1px;"
       tabindex="-1" />

Leave a Comment