Page 1 of 1

Disable backspace in browser (except proper use in forms)

Posted: Fri Jun 15, 2007 11:19 am
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. :!:

Posted: Fri Jun 15, 2007 4:40 pm
by feyd
It's generally very bad to disable any keys.

Posted: Fri Jun 15, 2007 5:06 pm
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.

Posted: Wed Jun 20, 2007 11:02 am
by icesolid
How would I make them cacheable?

Posted: Wed Jun 20, 2007 11:04 am
by Ambush Commander

Posted: Wed Jun 20, 2007 11:41 am
by icesolid
hmmm...I still need some help understanding the caching.

Posted: Wed Jun 20, 2007 1:27 pm
by Ambush Commander
Do you have any specific questions?

Posted: Wed Jun 20, 2007 1:34 pm
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.

Posted: Wed Jun 20, 2007 1:36 pm
by Ambush Commander
You set the appropriate caching headers. header() does the job well.

Posted: Wed Jun 20, 2007 1:44 pm
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.

Posted: Wed Jun 20, 2007 1:50 pm
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.