473,326 Members | 2,013 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,326 software developers and data experts.

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(inputElem) {
if (!inputElem.value) inputElem.value = 'Dad';
}
</SCRIPT><FORM>
<INPUT type='text' name='foo' value='Mom' onChange='changeNoted(this)'>
</FORM>
Jul 23 '05 #1
3 1749
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='changeNoted(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(inputElem) {
if (!inputElem.value) inputElem.value = 'Dad';
}
</SCRIPT><FORM>
<INPUT type='text' name='foo' value='Mom' onChange='changeNoted(this)'>
</FORM>


Weird Bug. How about this:

<INPUT type='text' name='foo1' value='Mom' onBlur='changeNoted(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='changeNoted(this)'>
</FORM>
<SCRIPT type='text/javascript'>
function changeNoted(inputElem) {
if (!inputElem.value) {
inputElem.value = 'Dad'; // all we should need, but for IE...
var cloned = inputElem.cloneNode(true);
if (cloned.value=='Dad') // Opera clone is fake (.value is 'Mom')
inputElem.parentNode.replaceChild(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
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...
3
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...
2
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...
2
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...
2
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...
5
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...
1
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...
2
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...
1
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...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.