Home Articles FAQs XREF Games Software Instant Books BBS About FOLDOC RFCs Feedback Sitemap
irt.Org
#

Q2066 How do I disable the ENTER key from activating the form submission?

You are here: irt.org | FAQ | HTML | Q2066 [ previous next ]

This can be achieved by submitting the form using the onClick event handler instead of onSubmit event handler. It is necessary to return false on event handler onSubmit to prevent submit on hitting ENTER key. Sample code:

<form name="form1" onSubmit="return false">
<input type="text">
<input type="button" value="SubmitForm" onClick="document.form1.submit()">
<a href="#" onClick="document.form1.submit()"><img src="button.gif"></a>
</form>

Feedback on 'Q2066 How do I disable the ENTER key from activating the form submission?'

©2018 Martin Webb