Disable Backspace On Form Pages

May 6, 2004

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;
}

if(window.event && window.event.keyCode == 8) {
// try to cancel the backspace
window.event.cancelBubble = true;
window.event.returnValue = false;
return false;
}
}

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?

View 3 Replies


ADVERTISEMENT

Way To Disable Backspace

Jun 25, 2004

Just a quicky how can i disable the backspace. I have found code for the enter key but dont understand it. code...

View 10 Replies View Related

How To Disable Backspace For Text

Jul 16, 2010

<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.

View 5 Replies View Related

Disable Back Button And Backspace?

Sep 4, 2007

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..?

View 9 Replies View Related

Disable Backspace Button (but Allow Text Correction)

Dec 14, 2005

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:

View 7 Replies View Related

Pages - Disable Going Backward ?

Apr 9, 2011

I want the pages in my website to go only forward and disable going backward, I mean the user can not go back to the previews page in some pages and I've been told that i can do that using javascript but I don't know how or using what.

View 2 Replies View Related

Disable Pages On Drop Down?

Jan 13, 2010

On my drop down for [url]... I have no information for Multimedia, Expeditions, Charity, Miscellaneous and more..

People are clicking these and just end up at a blank page.. Is there a way to make these unclickable?

When I was using dreamweaver I simply used a #. Now am on wordpress it's a but more trickey..

View 15 Replies View Related

How To Submit Form And Make TWO Pages Appear?

Aug 14, 2003

I would like to submit a form, and then have a results page appear... but also a small popup with another webpage.

View 1 Replies View Related

Does Form.disable Work On Hidden Text Form Elements?

Jul 23, 2005

Does "document.formName.elementName.disable" work on hidden form text
elements? I have a form with some input fields that are associated with
some hidden text fields and I would like to disable all of the
categories inside the form when the page loads and only enable each
category as it is needed. Code:

View 3 Replies View Related

Disable Form Objects Without Disabling Form Object Submition

Jul 23, 2005

How can I make an input box (or other objects) disabled or greyed out and
still have them submit in the form?

View 6 Replies View Related

Make A Form That Doesn't Switch Pages?

Oct 20, 2011

I'm new to Javascript, and I don't know how I should create HTML forms that don't redirect to a different page. I'm planning on making an application that lets you create a quiz and take it with as many questions as you want (using loops and arrays). I've done this in a number of languages, including Javascript, but I don't know how to tie this in to HTML so I don't have a web app that relies on pop-ups as the UI.

When you make a form, it asks for the action, which should be a different page. It then redirects to this page if a button is clicked, for instance. Given the nature of this quiz program that can theoretically create more questions than I have the ability to make separate web pages for, how do I do this? I don't plan on making 1,000 different pages with nearly identical code; this is what the loop is for.

[Code]...

View 2 Replies View Related

Filling Form Data On Existing Pages?

Jun 7, 2011

My friends and I have developed a chat service that uses Live Profiles to login to chat. The issue I am having is I need to autofill the login page with my email/password to speed up login and I was told JS would be the best way to do it, however, I can't seem to figure out how, lol. I tried sending the login info in a url and bookmarking the url to no avail. The link to the page is below.

View 1 Replies View Related

Search Multiple Intranet Pages With One Form?

Jun 24, 2011

There are multiple intranet pages with a list of names on them that are updated regularly.At the moment, there is no easy way to check if a name is on the pages without going in to each one at a time and searching them individually.

Is there a javascript script I could use to search all of the pages at the same time, and if a match is found, open the relevant page and highlight the result?

View 4 Replies View Related

JQuery :: Direct The Post And The Form Values To One Of Two Php Pages

Aug 4, 2011

I have a web form (yeah) that I would like to have jquery direct the post and the form values to one of two php pages depending on the choice selected.

Ideal flow:

If a person selects radio button "email" and clicks submitsend form values to page1

-Generate and send email and report success

-User never actually sees page1

If a person selects radio button"view" and clicks submit send form values to page2.

-Displaypage2

$(document).ready(function(){$("#listrequest_form").submit(function() {

View 7 Replies View Related

How To Allow CARRIAGE RETURN And BACKSPACE?

May 22, 2007

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>

View 1 Replies View Related

Create A Backspace Button?

Dec 7, 2010

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.

View 3 Replies View Related

Javscript Opposite-Backspace

Aug 24, 2007

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)?

View 3 Replies View Related

Go To Specific Page Using Backspace?

Feb 28, 2011

I have to go back to specific page(html page) using backspace button in javascript n html.

View 4 Replies View Related

JQuery :: Way To Simulate Backspace Button

Nov 4, 2010

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]...

View 4 Replies View Related

JQuery :: $.load On Form Pages - Can't Get Query Data In Processing Script

Jun 20, 2010

I have a database site I am currently designing, and would like to use a single page with forms in external html documents to undertake admin tasks (eg. add/remove records etc.)

I have managed to successfully load the form html into the necessary div using the $.load function, however, when I try to process the form, with this code:

$("#add_form").validate({
debug: false,
rules: {
maker: "required",

[Code]....

which asks 'process_form.php' to process the data, it doesn't seem to send the data in the form to the page. to confirm this, and whilst trying to get the system to work, the 'process_form.php' consists of 2 lines,:

echo $_GET['maker'];
echo '123456';

(ie. one line to return a string literal, and one line to return one of the variables which SHOULD be passed by the form)

This results in just the 123456 string being returned.

I have tried several things: loading the script above in the head of the 'parent' html page (ie. which the form is loaded into); - does not properly fire at all;

loading the script 'in-line' in the imported html - this leads to the result given above; running the script in an external script.js file through an onsubmit directive on the form...does not appear to properly fire the script.

View 4 Replies View Related

RegExp For Delete, Backspace And Arrow Keys

Nov 8, 2006

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>

<form>
<input type="text" onkeypress="return onKeyPressBlockNumbers(event);" />
</form>

View 9 Replies View Related

JQuery :: Enable Backspace Only When Textbox In Focus?

Nov 30, 2011

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.

View 3 Replies View Related

JQuery :: Text Without Backspace Get Error In Cluetip?

Sep 1, 2009

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?

View 2 Replies View Related

JQuery :: Preventing The Backspace Key Event From Firing?

Jun 22, 2011

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.

[Code]...

View 1 Replies View Related

Code Won't Run On Certain Pages/areas On Pages?

Sep 27, 2009

I coded the following JavaScript:

var el = document.createElement("iframe");
el.setAttribute('id', 'ifrm');
document.body.appendChild(el);
el.setAttribute('height', 250);

[Code].....

And am putting it between <script type="text/javascript"> and </script> tags in the <body> section of my site. But, it only works in certain areas of the page.

View 6 Replies View Related

Disable Enter Within Form

Feb 25, 2007

I have a form with the following structure:

<form onsubmit="getsearchdata();">
lots of input boxes here
<input type="submit" name="submit" onsubmit="getsearchdata();">
</form>

In Opera, whenever someone presses the <enterbutton, the form is
submitted and the onsubmit does not event get any attention. When the
submit button is clicked, it obviously works.

View 2 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved