PDA

View Full Version : Disable Enter Key to Submit Form, but not Enter Key for one specific textbox


igloogod
05-28-2007, 04:38 AM
Hello,

I need to disable the Enter Key to prevent it from Submitting the Form, on all form elements except one specific textbox that is mult-line text field.

Here is what DOES work to disable enter key, but it disables it on the specific field as well. The field is called narrativetxt.

onkeypress="{ var key; if(window.event) key = window.event.keyCode; else key = e.which; if(key == 13) return false; else return true;}"

Thanks

_Aerospace_Eng_
05-28-2007, 05:05 AM
http://www.dynamicdrive.com/dynamicindex16/disableenter.htm

igloogod
05-28-2007, 07:39 AM
Thank you.. but I didn't clarify.. I am hoping to NOT have to modify each field.. This is a HUGE form.. I was hoping I could just have some javascript syntax assistance that would allow me to add something like... & document.forms['form1'].elements != ['narrativetxt']...to the existing script i have
{ var key; if(window.event) key = window.event.keyCode; else key = e.which; if(key == 13) return false; else return true;}

so ... something like...
{ var key; if(window.event) key = window.event.keyCode; else key = e.which; if(key == 13) & document.forms['form1'].elements != ['narrativetxt'] return false; else return true;}"

But I am certain that this syntax is WAY off.

Thanks for any help.

igloogod
05-30-2007, 12:54 AM
can someone respond? thanks