Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Stop submit on enter in IE

Status
Not open for further replies.

mrichards

Programmer
Nov 18, 2000
74
CH
Is there a simple way of stopping Internet Explorer form submitting a form when someone who is filling in a form hits the enter key? I've seen some fairly elaborate java scripts but I just need something simple.

thanks
Mark
 
This is about as simple as I can think of.
Code:
<form name=... action=... onSubmit=&quot;return false&quot;>
Form Elements Here
Code:
<input type=&quot;button&quot; value=&quot;Submit&quot; onClick=&quot;this.form.submit();&quot;>
</form>

Important, the Submit button that I created is of the button type and not the submit type. Otherwise the form will never submit.

If you're already using some JavaScript validation on this form and need some help threading this into that, let me know.

ToddWW
 
you could also use an onkeydown event to ignore a Return Key

<input type=text onkeydown=&quot;if (event.keyCode==13) return false;&quot;>

however this would have to be placed in each form element that you wanted the return key to NOT submit the form.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top