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>
> 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.
Weird Bug. How about this:
<INPUT type='text' name='foo1' value='Mom' onBlur='changeNoted(this)'>
Mike
<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