The Little Guy Posted January 24, 2009 Share Posted January 24, 2009 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/142222-internet-explorer-type-property/ Share on other sites More sharing options...
Psycho Posted January 24, 2009 Share Posted January 24, 2009 I remember trying to do the same thing ago a long time back. Forget what I did then, but one workaround would be to use two separate fields and use the display property to make it look like it's changing to a password field. function showPW() { document.getElementById('pwText').style.display = 'none'; pwField = document.getElementById('pwPWord'); pwField.style.display = ''; pwField.focus(); pwField.select(); } <input id="pwText" type="text" onfocus="showPW();" value="Password" /><input id="pwPWord" type="password" value="Password" style="display:none;" /> Link to comment https://forums.phpfreaks.com/topic/142222-internet-explorer-type-property/#findComment-745120 Share on other sites More sharing options...
haku Posted January 24, 2009 Share Posted January 24, 2009 try: this.setAttribute('type', 'password') Although I'm not sure that setAttribute with 'type' is IE friendly. edit: why don't you just make it a password field in the first place? Link to comment https://forums.phpfreaks.com/topic/142222-internet-explorer-type-property/#findComment-745157 Share on other sites More sharing options...
dropfaith Posted January 24, 2009 Share Posted January 24, 2009 try: edit: why don't you just make it a password field in the first place? I assume its not password as he sets a defualt value to it and adding a default to a password field would only display********* instead of the word password Link to comment https://forums.phpfreaks.com/topic/142222-internet-explorer-type-property/#findComment-745158 Share on other sites More sharing options...
haku Posted January 24, 2009 Share Posted January 24, 2009 ahh, makes sense. Link to comment https://forums.phpfreaks.com/topic/142222-internet-explorer-type-property/#findComment-745162 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.