faqts : Computers : Programming : Languages : JavaScript

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

46 of 57 people (81%) answered Yes
Recently 7 of 10 people (70%) answered Yes

Entry

how do i prevent an enter key from submiting a form?

Apr 7th, 2008 22:52
ha mo, qsdqsd Gapeau, bob johnson,


I presume the question is
 "how do i prevent the 'enter' key from submiting a form ?"
The way I use :
8<------------------------------------------------------------------------
<form onSubmit="return false">
  ...
  <input type="button" value="My special submit button" 
onClick="this.form.submit()">
</form>
8<------------------------------------------------------------------------
1) The 'return' key will be catch by 'onSubmit' and will not submit the
form (return false).
2) The button will call form.submit() bypassing the onSubmit.
et voilą !
--
qsdqsd
http://www.businessian.com
http://www.computerstan.com
http://www.financestan.com
http://www.healthstan.com
http://www.internetstan.com
http://www.moneyenews.com
http://www.technologystan.com
http://www.zobab.com
http://www.healthinhealth.com