Disabling "Enter"

Results 1 to 2 of 2

Thread: Disabling "Enter"

  1. #1
    Join Date
    Dec 1969

    Default Disabling "Enter"

    I&#039m looking for a way to disable the "enter" button while filling out a form. User habit dictates pressing ENTER before a form is completed, and a project we are currently developing requires "tab" use over "enter". Is there a way to disable enter, or possibly tell it to act as a tab function, and let SUBMIT do the actual work when the form is complete? I would appreciate any help at all on this.

  2. #2
    elaine Guest

    Default RE: Disabling

    Check this out it is the solution to your problem.<BR><BR><BR>On your page, you have to define onkeydown event handlers for each control that the user can use. For example, if your form has 2 text boxes named txtTest1 and txtTest2, this could be your event handlers:<BR><BR>function window.document.frmName.txtTest1.onkeydown()<BR>{< BR> SetFocus();<BR>}<BR>function window.document.frmName.txtTest2.onkeydown()<BR>{< BR> SetFocus();<BR>}<BR><BR>Next, you define a function named SetFocus. This function will be called when users press a key on the keyboard. keyCode 13 represents the enter key. The following code will submit the form whenever users press the enter key, no matter which field is currently selected:<BR><BR>function SetFocus()<BR>{<BR> if (window.event.keyCode == "13")<BR> {<BR> document.all.btnSave.focus();<BR> }<BR>}<BR><BR>Returning null in the SetFocus function may prevent the form from being submitted<BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts