473,396 Members | 1,940 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

esc key clears html input text values

Hi,
I have created 2 html input text boxes with readonly property set to 'readonly'. I am handling the esc key event(27) in javascript code. When I press the esc key for the first time it will not harm any thing. But if i press the esc key 2nd time it will clear both the input text box values. Please let me know is this the correct behavior? What should I do to retain the text values?

Thanks,
Nags
Oct 1 '09 #1
3 4098
Dormilich
8,658 Expert Mod 8TB
@coolnags
and how do you do that?
Oct 1 '09 #2
I have attached the hadnler using AddHandler api for keydown of the text box whose text is getting cleared. I am using IE6.
Oct 5 '09 #3
IE does this, it is a default behavior, it acts like a form reset button, much the same way that hitting Return does a form submit.

It does not seem to be a very likely thing for a user to do by accident. There are a TON of hotkeys which can affect your browser, you can not stop all of them: http://www.accessible-devices.com/IE7HotKeys.html

The only way to retain the values is if they have been assigned in the value="" part when the page is loaded (that is what reset does - resets to the values the fields had when the page loaded). Typically this means hard coding or pre-populating the values on the server side: <input type="text" value="<%=SomeVarible%>">

P.S.

I did notice that it seems to only happen if you have set focus to a field. Maybe setting focus to something outside of the form will work for you.
Aug 31 '12 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: Gary | last post by:
I haver a table of students - Say 100 students that I need to be able to update/delete and amend. I know I can do this one student at a time which is simple but lets say I want to see all the...
4
by: frogman042 | last post by:
My daughter is playing around trying to learn JavaScript and she wrote a small program that prints out a message in increasing and decreasing font size and color changes. She is using document...
3
by: Urs Eichmann | last post by:
Hello I have an ASP.NET web site where you can page through lists by using INPUT TYPE=image buttons. I noticed that, in IE6, the whole page gets cleared and built again from the ground up, whereas...
3
by: musosdev | last post by:
Hi I want to have a textbox on my webpage that shows 'Type here' in gray. When you click on the textbox, that text disappears and you can type your search, rather than having to select it and...
3
by: lcjohnso | last post by:
Hi all, Does anyone know if there is an easy way to create the html representation of an HTMLElement object in javascript? I'm attempting to update the innerHTML property of a div element to...
5
by: joker | last post by:
I'm somewhat of a newbie to PHP, however i would appreciate if someone would be kind enough and help me with my problem. To give you a better understanding of what my problem is, here is what i'm...
14
by: jcage | last post by:
Is there any tutorials online for sending email through forms? I can send an email as well as write to my MySQL database from home with the following code but not at work. I think there might be...
19
Atli
by: Atli | last post by:
Introduction At some point, all web developers will need to collect data from their users. In a dynamic web page, everything revolves around the users input, so knowing how to ask for and collect...
1
by: since | last post by:
I figured I would post my solution to the following. Resizable column tables. Search and replace values in a table. (IE only) Scrollable tables. Sortable tables. It is based on a lot...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.