codingmasterRS Posted July 7, 2010 Share Posted July 7, 2010 I have a text field, and when a user clicks on it, it turns into a password field. to accomplish this, I have this in an onfocus method in the input: <input type="text" onfocus="this.type='password';" value="Password" /> This works perfectly fine in Firefox, but in Internet Explorer, I have an error message saying: Could not get the type property. This command is not supported. How can I fix this in Internet Explorer? Link to comment https://forums.phpfreaks.com/topic/206975-thistypepassword/ Share on other sites More sharing options...
codingmasterRS Posted July 7, 2010 Author Share Posted July 7, 2010 bump Link to comment https://forums.phpfreaks.com/topic/206975-thistypepassword/#findComment-1082488 Share on other sites More sharing options...
joePHP Posted July 7, 2010 Share Posted July 7, 2010 Check this out: http://www.dynamicsitesolutions.com/javascript/change-input-type-dynamically/ Link to comment https://forums.phpfreaks.com/topic/206975-thistypepassword/#findComment-1082495 Share on other sites More sharing options...
codingmasterRS Posted July 14, 2010 Author Share Posted July 14, 2010 still not solved Link to comment https://forums.phpfreaks.com/topic/206975-thistypepassword/#findComment-1085851 Share on other sites More sharing options...
joePHP Posted July 14, 2010 Share Posted July 14, 2010 Hi, It seems that you can't change the type in IE. But what you can do is start off with a text input and then remove it from the DOM and instead create a password input. Something like this: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <style type="text/css"> </style> <script type="text/javascript"> function changeType(txt) { //Remove input type text var frm = document.getElementById('frm'); frm.removeChild(txt); //Create input type password var new_pass = document.createElement('input'); new_pass.setAttribute('type', 'password'); new_pass.setAttribute('id', 'pass'); frm.appendChild(new_pass); new_pass.focus(); } </script> <title></title> </head> <body> <form id="frm" action="" method="post"> <input type="text" id="txt_pass" value="Password" onfocus="changeType(this);" /> </form> </body> </html> I hope this helps, Joe Link to comment https://forums.phpfreaks.com/topic/206975-thistypepassword/#findComment-1085868 Share on other sites More sharing options...
codingmasterRS Posted July 14, 2010 Author Share Posted July 14, 2010 genius, thanks Link to comment https://forums.phpfreaks.com/topic/206975-thistypepassword/#findComment-1085875 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.