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?

2 of 26 people (8%) answered Yes
Recently 1 of 10 people (10%) answered Yes

Entry

How do I cancel a key press in an input box in NS6 -- I can't get preventDefault() to work?

Apr 6th, 2008 19:34
ha mo, Dave Clark, Colin Fraser, Jim Fuqua,


You cannot cancel a keystroke, that is a very difficult thing to even
attempt, but what you can do is to trap the keystrokes as they are 
made,
see of they correspond to a pre-determined list of acceptable
keystrokes. If it does not, then just refuse to process it. 
There are a number of querstions answered in this forum that provide an
answer to how that is done. Find one and adapt it to your need. (BTW, I
wrote several of them, and I know they all work.) 
Good luck..
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     I don't have NS6 anymore to test with, but I'm pretty sure 
cancelling a keystroke works in NS6 the same as in IE -- which is 
through the use of the onkeydown event.  Just return a false value to 
that event, from the event handler, when an invalid keystroke is 
detected.
Take care,
Dave Clark
www.DaveClarkConsulting.com
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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