Hello everyone, here's my dilemma:
I am using the below code to clear the default text in an input box.
The issue I am having, is when the user pushes enter on the keyboard, it transfers them to the script page, and from what I can tell doesn't even try to run it. Everything is fine if they click submit instead though!? I've been round and round with the php, and it's pretty simple code, so I'm confident the issue is in the javascript.Code:addEvent(window, 'load', init, false); function init() { var formInputs = document.getElementsByTagName('input'); for (var i = 0; i < formInputs.length; i++) { var theInput = formInputs[i]; if (theInput.type == 'text' && theInput.className.match(/\bcleardefault\b/)) { /* Add event handlers */ addEvent(theInput, 'focus', clearDefaultText, false); addEvent(theInput, 'blur', replaceDefaultText, false); /* Save the current value */ if (theInput.value != '') { theInput.defaultText = theInput.value; } } } } function clearDefaultText(e) { var target = window.event ? window.event.srcElement : e ? e.target : null; if (!target) return; if (target.value == target.defaultText) { target.value = ''; } } function replaceDefaultText(e) { var target = window.event ? window.event.srcElement : e ? e.target : null; if (!target) return; if (target.value == '' && target.defaultText) { target.value = target.defaultText; } }
Also, please note, that this only occurs using Internet Explorer. I can't replicate this bug in Firefox. Any ideas?



Reply With Quote
Redirect people to this thread in your other post.



Bookmarks