faqts : Computers : Programming : Languages : JavaScript : Forms

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

48 of 54 people (89%) answered Yes
Recently 8 of 10 people (80%) answered Yes

Entry

How can I prevent the ESC key from resetting a complet FORM in IE?

Jun 10th, 2000 08:32
Martin Honnen,


IE seems to have the habit of resetting the complete form when you 
press ESC inside a form element. The following code prevents that

<HTML>
<HEAD>
<STYLE>
</STYLE>
<SCRIPT>
if (document.all)
  document.onkeydown = function () {
    return event.keyCode != 27;
  }

</SCRIPT>
</HEAD>
<BODY>
<FORM NAME="formName">
<INPUT TYPE="text" NAME"field1">
<BR>
<INPUT TYPE="text" NAME"field2">
<BR>
<INPUT TYPE="text" NAME"field3">
<BR>
<INPUT TYPE="text" NAME"field4">
<BR>
<INPUT TYPE="submit">
<INPUT TYPE="reset">
</FORM>
</BODY>
</HTML>