<script language="javascript">
function disableback(evt) {
if (evt.keyCode == 8 || evt.which == 8) {
return false; /*have also tried return (evt.keyCode != 8) and evt.which == 46 and the variations*/
}}
</script>
<input type="text" onkeydown="disableback(event)" onkeypress="disableback(event)">
I am doing my testing on Firefox. From posts this should work to stop from the page going back yet no dice. I currently have the text area in a frame and have it reload keeping all text in a variable, it just seems awful sloppy.
This may work on IE, have yet to test. Just trying for FF atm.
Im trying to find a way to disable the keyboard backspace button from going back a page but allowing it to go back a character.
The problem happens with our webmail client when composing a message, if the cursor is not in the textarea and backspace is clicked it goes back a page and everything typed in the textarea is lost, its easy to do because we use a cms menu thats always active, and distract the cursor, and its very frustrating. Code:
I've been getting some complaints from my users: when filling out forms, while on a select box, pressing the backspace key would actually mimick pressing the back button (like history.go(-1) ...)
Then I realized that if the user wasn't in a textbox or a textarea, pressing the backspace key would send them back one page. Now I've got a multi-page form in an iFrame and that's really screwing their inputs up as it loses all the information entered in that form (pressing back doesn't submit/post backwards... I wish it would!).
So anyway, here's the script I'm using on all my pages so that the user won't 'accidentally' go back a page. (In my opinion, with my users anyway, a user shouldn't need to hit the backspace unless they're in a textbox or a textarea).
//so backspace doesn't go back document.onkeydown = checkForBackspace; function checkForBackspace() { //we can backspace in a textbox if(window.event.srcElement.type.match("text")) { return true; }
This is IE only. srcElement is an IE thing.. I believe most other browsers use target. I don't know what else would be different, but anyway, that's what I'm using.
BTW: If you're wondering why anyone would press backspace in a selectbox, well I recently showed them that you can press the first letter of an item in the list to quickly jump to that item. Well, perhaps naturally, if they press the wrong key, instead of pressing the right key, they try to hit backspace first. Just if you were curious... I guess checkboxes and radios could be similar?
In my web application(ASP.net), i need to disable the "Back" button in the browser.Moreover i also need to disable the Backspace key in my keyboard when my web page is run..How to do it with javascript..?
When i have:title="test|contentwithoutspaceeeeeeeee">hover</a>if the width of the text is more bigger than the configuration ofcluetip, the text continues out of cluetip box.Have one way to solve that?
This JS limits the input characters into the form. How do I modify it so that it also allows CARRIAGE RETURN and BACKSPACE (for making text correction)?
Due to the template engine I am using, I cannot use IF/ELSE statement.
<form>
<textarea name="event_description" ONKEYPRESS="if (document.layers) var c = event.which; else if (document.all) var c = event.keyCode; else var c = event.charCode; var s = String.fromCharCode(c); return /[0-9a-zA-Zs,.?!@#$%&*()-]/.test(s);"></ textarea> </form>
I have created a keyboard on Taco HTML via a table of buttons and within this keyboard I need a functioning Backspace button using javascript. I currently have a 'reset' button which clears all of the values in the text box.
Could someone point me in the right direction for making a key function that removes one character from the beginning of a string every time it is pressed (basically the exact opposite of a backspace key)?
I have a keypad that inserts a number into a div (simulates pin number). How do i create a "backspace" or delete button that will remove the last character added.[code]...
I'm using the below to limit the input into a text box to just letters, numbers, hyphens and full stops, but I also need to allow the backspace, delete and arrow keys to come through. How can I do this?
<script language="JavaScript" type="text/javascript"> <!-- function onKeyPressBlockNumbers(e) { var key = window.event ? e.keyCode : e.which; var keychar = String.fromCharCode(key); reg = /^[.a-zA-Z0-9_-]*$/; return reg.test(keychar); } //--> </script>
I have a modal window with a few textboxes, one button and a few labels. I need to disable the backspace key, unless any of textboxes is in focus, if this the case, user allows to delete the text from the textbox.
I have a form element that is readonly. <input type="text" id="kfs_acct_1" readonly="false" /> This field is dynamically populated an making it readonly prevents users from changing the value in this field. The problem I have is users click on the field and try to delete it's value. They click in the field and hit their Backspace key. This takes them away from the page to the page from whence they came. Because of the way the form is set up, doing this makes them loose all the data in the form (the one with the readonly box). How can I prevent the Backspace key from fireing and taking the user away from this page? I've tried a few things, but apparently making a field readonly keeps some key events from being seen.
Is there a javascript code so that you can disable a textarea but parts of the page can still add to the textarea if your peter i mean about the other javascripts you told me. Sorry if this is confusing just ask me and i will rewrite it
In the following code I just want to disable the textbox if “other Amount is selected”, radio element 7.I have been working at this too long cause I can’t see the problem.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html>
I have two radio box ()Premium Listing, () Free Listing now I want to disable all those input field (text box) having class="paidfield" when I click on ()Free Listing and enable when I click on () Premium List.I need this in Mootool because my application is using Mootool only.
I'm having problems getting a script to work. When a certain option value is selected it is supposed to enable a text field. However, it's not working and I'm not sure why. Here's the code:
working on a project at the minute but have dug a hole in javascript for myself on this one. The objective was to use cookies to save a form whilst a file was being upload at the same time on the same page.To get the filename for the uploading mp3 file inserted into the user current form which then is posted on submit to a directory where its viewable for download, the page must refresh and a query string is used to put the uploaded files name into the form.What i wanted though was the user to be able to write out there tracklist whilst there file was being uploaded so they can make the most of the time and do 2 things at once.Getting round this was ok using cookies to remember the forms input values and restoring them once the page had refreshed.
The problem is thought the cookie script will only write once to file if the text box that gets updated with a new value being the uploaded file value changes,to get round this i wanted to disable the radio button that saves the form upon change of the default value of the mirror1_url text input as the upload session is complete and the user would not need to recall the cookies values.a working version with the above problem can be found here http://urban-love.co.uk/uploads/userupload.phpim sure its only a few lines of script you can see I have implemented one in the page already see view source but it takes no effect in this form for some reason?