gevans Posted January 30, 2009 Share Posted January 30, 2009 OK, here's the javascript; function clearPassField(obj){ var newInput = document.createElement('input'); newInput.setAttribute('type','password'); newInput.setAttribute('name',obj.getAttribute('name')); obj.parentNode.replaceChild(newInput,obj); newInput.focus(); } and here's the two inputs that use it; <input type="text" id="cemail" name="cemail" value="Confirm E-mail Address" onclick="clearField('Confirm E-mail Address', this.id)" onblur="checkField('Confirm E-mail Address', this.value, this.id)" /><br /> <input type="text" id="pass" name="pass" value="Password" onclick="clearPassField(this)" /><br /> Haven't bothere with IE6 yet, but so far IE7 and IE8 don't like it, everything works fine appart from the final focus() which works in Safari, FF2, FF3 etc... Quote Link to comment Share on other sites More sharing options...
landavia Posted January 30, 2009 Share Posted January 30, 2009 this is complicated JS well... how about add var before var newInput = document.createElement('input'); then var newInput; newInput = document.createElement('input'); and i was think this obj.parentNode.replaceChild(newInput,obj); perhaps the problem? Quote Link to comment Share on other sites More sharing options...
gevans Posted January 30, 2009 Author Share Posted January 30, 2009 That's not the problem, this is working in FF and Safari, it's just an issue with IE and focus() Quote Link to comment Share on other sites More sharing options...
gevans Posted January 30, 2009 Author Share Posted January 30, 2009 Ok, I've fixed it. IE is such a fussy bastard that it has to wait a second before it can focus, otherwise the element hasn't settled in properly and thinks it doesn't exist. so I changed the line; newInput.focus(); to setTimeout(function() { newInput.focus(); }, 10); Quote Link to comment Share on other sites More sharing options...
landavia Posted January 30, 2009 Share Posted January 30, 2009 sry.. i mean that problem will have problem on IE and yeah.. that's bastard IE.. i wonder is related to SP 2? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.