473,804 Members | 3,247 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

IE not detecting onChange properly - can I compensate?

If I detect an empty textbox, I fill it with a value ('Dad').
If I do this twice, the second time around IE 6 fails to notice
that I've cleared the textbox again, thus leaving the textbox
cleared. Is there a recommended workaround?
Opera 7.23 is detecting the second deletion fine.

Thanks,
Csaba Gabor

The page snippet below illustrates what I mean:

<SCRIPT type='text/javascript'>
function changeNoted(inp utElem) {
if (!inputElem.val ue) inputElem.value = 'Dad';
}
</SCRIPT><FORM>
<INPUT type='text' name='foo' value='Mom' onChange='chang eNoted(this)'>
</FORM>
Jul 23 '05 #1
3 1776
Csaba Gabor wrote:
If I detect an empty textbox, I fill it with a value ('Dad').
If I do this twice, the second time around IE 6 fails to notice <INPUT type='text' name='foo' value='Mom' onChange='chang eNoted(this)'>


IE sucks. Use "onblur" instead of "onchange".
Regards,
Yep.
Jul 23 '05 #2
Csaba Gabor wrote:
If I detect an empty textbox, I fill it with a value ('Dad').
If I do this twice, the second time around IE 6 fails to notice
that I've cleared the textbox again, thus leaving the textbox
cleared. Is there a recommended workaround?
Opera 7.23 is detecting the second deletion fine.

Thanks,
Csaba Gabor

The page snippet below illustrates what I mean:

<SCRIPT type='text/javascript'>
function changeNoted(inp utElem) {
if (!inputElem.val ue) inputElem.value = 'Dad';
}
</SCRIPT><FORM>
<INPUT type='text' name='foo' value='Mom' onChange='chang eNoted(this)'>
</FORM>


Weird Bug. How about this:

<INPUT type='text' name='foo1' value='Mom' onBlur='changeN oted(this)'>

Mike

Jul 23 '05 #3
Ahem. The following compensates for the mentioned Microsoft bug.
Evidently, clones are not quite identical, ha ha.

<FORM>
<INPUT type='text' name='foo' value='Mom' onChange='chang eNoted(this)'>
</FORM>
<SCRIPT type='text/javascript'>
function changeNoted(inp utElem) {
if (!inputElem.val ue) {
inputElem.value = 'Dad'; // all we should need, but for IE...
var cloned = inputElem.clone Node(true);
if (cloned.value== 'Dad') // Opera clone is fake (.value is 'Mom')
inputElem.paren tNode.replaceCh ild(cloned, inputElem);
}
}
</SCRIPT>

Csaba Gabor
only tested on IE 6 and Opera 7.23
Note: this method introduces orphan nodes into the DOM
Jul 23 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
7661
by: Ryan McGeary | last post by:
In a <select> drop-down, the onchange event isn't called when scrolling through the dropdown using the mouse-wheel and when crossing over a new <optgroup>. Using the example below, notice how the onchange event isn't called when mouse wheel scrolling between A3 and B1, but it works properly when scrolling between A1 and A2. E.g. ------------------------------------------
3
5186
by: Holden Caulfield | last post by:
Does anyone know how to detect if a user has pasted code using the right mouse button into a textarea? I have fields in a form that autoupdate when text is changed in a textarea, but if it is pasted using the mouse (not CTRL-V) the trigger doesn't happen. I tried onChange first, no luck. Detecting keystrokes and LEFT mouseclicks was easy enough, and it works for those. But SOME users paste stuff in without ever typing or...
2
3138
by: DonD | last post by:
I have a form that allows a user to upload a file. When they select a file (onChange), I call a JS function that analyzes the filename for specific keywords and then populates a multiple select box with the keywords. The problem is, IE for Mac doesn't do the onChange properly. In all other browsers, as soon as I select the file, the onChange fires and the filename gets analyzed, etc. In IE for Mac, I have to click away from the file...
2
1407
by: Simon Harvey | last post by:
Hi all, Is there any easy way to check a field for calues that have changed on a post back. So the page is sent to the user, the user changes some values and I need to know which ones changed. Is the only way to do this to go through all the fields and check them against their old values. In which case, would I need to store the values in
2
1674
by: ASP.Confused | last post by:
How would I go about detecting a memory leak? My web hosting provider has our site set up to only have a root "bin" folder for .NET apps, and I would like to be able to watch how much memory is being allocated for the entire site (since the site acts as one big application.) Is there anyway to do this through code? The reason I ask is because occasionally, our site will start having session state loss. After a day or two, it goes back...
5
8793
by: Z.K. | last post by:
In C#, using the StreamReader, how do I detect when you get to the end of line. I am reading a text file using the Read() function and I need to detect the \n\r, but everything I try does not work. I am sure that this probably fairly simple, but I have not been able to figure it out. Z.K.
1
2539
by: seahorse298 | last post by:
I am using MS Access 2000 on a Windows XP machine. I have a list form, listing the number of companies a business is dealing with. I have a filter field on the form which is used to filter the list as characters are typed in the filter field, using the OnChange event for the field. Generally the filter works fine except when a company name contains a space. The space seems to get ignored in the code for the OnChange event. Ihave checked...
2
2879
by: waleed | last post by:
I'm not really good with javascript, basically what I'm trying to do is that I want to be able to handle when the status of a checkbox is changed (i.e. checked or unchecked), I see everybody is using onclick but I wonder if this is the correct approach, what if a user changes the status of the checkbox using the keyboard, will onclick be triggered? I know I might sound a little picky here but I believe those people who created DHTML...
1
3087
omerbutt
by: omerbutt | last post by:
hi i am making a intranet online test application for a school and for that i have to make a form for creating the test the logic is to select a subject and then the number of questions for that test initially there are only 2 select elements in the form namely the , subjects and the totalQuestions when it selects the choice in the totalQuestions dropdown it calls an onchange function makeAnswere(choice,rowId) which checks if the choice is, ...
0
9588
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10589
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10340
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10327
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9161
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7625
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6857
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4302
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2999
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.