OT: Using Javascript to disable backspace key with exception
I am using Javascript to disable backspace key. It works fine. The only problem is that I need to have the backspace key functional for only one field on my form. Here is the current script I am using: - function checkShortcut() { if(event.keyCode==8 || event.keyCode==13) { return false; } } - How can I modify this script to include backspace for my one textbox? Thanks in advance!! ~| Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4 Subscription: http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribe&forumid=4 FAQ: http://www.thenetprofits.co.uk/coldfusion/faq Signup for the Fusion Authority news alert and keep up with the latest news in ColdFusion and related topics. http://www.fusionauthority.com/signup.cfm
Re: OT: Using Javascript to disable backspace key with exception
event.fromElement wiil give you the object which generated the event. Test for that being the input you want to allow backspace in and block it in all other cases. Robert J. Polickoski Senior Programmer, ISRD Inc. (540) 842-6339 [EMAIL PROTECTED] AIM - RobertJFP -- Original Message -- From: "James Taavon" <[EMAIL PROTECTED]> Reply-To: [EMAIL PROTECTED] Date: Fri, 8 Nov 2002 09:52:27 -0500 >I am using Javascript to disable backspace key. It works fine. The only >problem is that I need to have the backspace key functional for only one >field on my form. > >Here is the current script I am using: >- > >function checkShortcut() >{ >if(event.keyCode==8 || event.keyCode==13) >{ >return false; >} >} > > >- > >How can I modify this script to include backspace for my one textbox? > > >Thanks in advance!! > > ~| Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4 Subscription: http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribe&forumid=4 FAQ: http://www.thenetprofits.co.uk/coldfusion/faq Structure your ColdFusion code with Fusebox. Get the official book at http://www.fusionauthority.com/bkinfo.cfm
Re: OT: Using Javascript to disable backspace key with exception
You are calling this function onKeyDown right? Just leave the function call out on the textarea you don't want to trap the backspace key on. Also event.which is NS4's version of event.keyCode. If you do a little object detection you can make this script work cross browser... if (document.all) keyPressed = event.keyCode; if (document.layers) keyPressed = event.which -- jon mailto:jonhall@;ozline.net Friday, November 8, 2002, 9:52:27 AM, you wrote: JT> I am using Javascript to disable backspace key. It works fine. The only JT> problem is that I need to have the backspace key functional for only one JT> field on my form. JT> Here is the current script I am using: JT> - JT> JT> function checkShortcut() JT> { JT> if(event.keyCode==8 || event.keyCode==13) JT> { JT> return false; JT> } JT> } JT> JT> - JT> How can I modify this script to include backspace for my one textbox? ~| Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4 Subscription: http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribe&forumid=4 FAQ: http://www.thenetprofits.co.uk/coldfusion/faq This list and all House of Fusion resources hosted by CFHosting.com. The place for dependable ColdFusion Hosting.