Disable backspace in browser (except proper use in forms)

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
icesolid
Forum Regular
Posts: 502
Joined: Mon May 06, 2002 9:36 pm
Location: Buffalo, NY

Disable backspace in browser (except proper use in forms)

Post by icesolid »

I was just wondering if it is possible to disable the delete key from going back in the web browser (Internet Explorer).

The reason I want to do so is that I have users typing long paragraphs in a form and if they click outside of the form box on accident and hit the delete key to delete a word or something in their paragraph and do not realize they are outside of the form box their browser goes back and they lose what they typed in the form box.

Basically i need code to disable backspace in browser (except proper use in forms).

I have tried searrching Google but have only really found solutions for FireFox.

Any ideas/suggestions?

P.S. I think that this is the right category to post this thread in because I figure JavaScript would be used somehow. If I posted this thread in the wrong category I am sorry. :!:
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

It's generally very bad to disable any keys.
User avatar
Ambush Commander
DevNet Master
Posts: 3698
Joined: Mon Oct 25, 2004 9:29 pm
Location: New Jersey, US

Post by Ambush Commander »

Two solutions that don't involve disabling keys:

1. Autosave. Kinda difficult to implement.

2. Make your forms cacheable. Then, when they click the forward button, they'll get their old content. Try it.
icesolid
Forum Regular
Posts: 502
Joined: Mon May 06, 2002 9:36 pm
Location: Buffalo, NY

Post by icesolid »

How would I make them cacheable?
User avatar
Ambush Commander
DevNet Master
Posts: 3698
Joined: Mon Oct 25, 2004 9:29 pm
Location: New Jersey, US

Post by Ambush Commander »

icesolid
Forum Regular
Posts: 502
Joined: Mon May 06, 2002 9:36 pm
Location: Buffalo, NY

Post by icesolid »

hmmm...I still need some help understanding the caching.
User avatar
Ambush Commander
DevNet Master
Posts: 3698
Joined: Mon Oct 25, 2004 9:29 pm
Location: New Jersey, US

Post by Ambush Commander »

Do you have any specific questions?
icesolid
Forum Regular
Posts: 502
Joined: Mon May 06, 2002 9:36 pm
Location: Buffalo, NY

Post by icesolid »

How do you cache the fields in the form to repalce them selves if the user hits the backspace button outsdie of the form and accidentally browses back.

They are filling out about 150 form fields on a inspection questionaire.
User avatar
Ambush Commander
DevNet Master
Posts: 3698
Joined: Mon Oct 25, 2004 9:29 pm
Location: New Jersey, US

Post by Ambush Commander »

You set the appropriate caching headers. header() does the job well.
User avatar
AKA Panama Jack
Forum Regular
Posts: 878
Joined: Mon Nov 14, 2005 4:21 pm

Post by AKA Panama Jack »

Ambush Commander wrote:You set the appropriate caching headers. header() does the job well.
That will not CACHE form data that hasn't been sent yet by the browser.

Basically you are completely out of luck in this matter when it comes to IE.

You might add a suggestion that the site works better in another browser. Opera will automatically cache form data that has been input. If they accidentally move back one of more pages they can always move forward back to the form and the form will still contain what they have input. I don't know of Safari or Firefox have this ability but it has been a lifesaver for me for years using Opera.
User avatar
Ambush Commander
DevNet Master
Posts: 3698
Joined: Mon Oct 25, 2004 9:29 pm
Location: New Jersey, US

Post by Ambush Commander »

What version are you using? I know for a fact that Firefox, IE6 and IE7 "remember" form data if the page can be cached. You can try it yourself: create a plain HTML file with a form-field in it. Browse to it, type something in, press backspace outside of the form, then press forward.

This will not work if you have no-cache headers sent (which PHP sends by default when sessions are used). This is also assuming that the form page itself is not from a POST request.
Post Reply