The Little Guy Posted March 13, 2010 Share Posted March 13, 2010 How can I switch a text field to a password field in internet explorer? I have tried this.getAttribute('type'), and this.setAttribute('type', 'password') I have also tried this.type = 'password' IE doesn't support any of those. Quote Link to comment Share on other sites More sharing options...
slurpee Posted March 14, 2010 Share Posted March 14, 2010 I don't think IE likes changing input types, so you'll have to replace the current text input object with a newly generated password input object. Something like this: function replaceInput(oldInput){ var newInput=document.createElement('input'); newInput.setAttribute('type','password'); newInput.setAttribute('name',oldInput.getAttribute('name')); oldInput.parentNode.replaceChild(newInput,oldInput); newInput.focus(); } Thing is, IE doesn't seem to put the focus on the new password input. Quote Link to comment Share on other sites More sharing options...
The Little Guy Posted March 14, 2010 Author Share Posted March 14, 2010 ahh!!! good idea! never thought of doing that! 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.