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. Link to comment https://forums.phpfreaks.com/topic/195082-change-text-field-type/ 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. Link to comment https://forums.phpfreaks.com/topic/195082-change-text-field-type/#findComment-1025839 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! Link to comment https://forums.phpfreaks.com/topic/195082-change-text-field-type/#findComment-1026025 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.