dsp77 Posted September 6, 2010 Share Posted September 6, 2010 i have figured how to change the input type from password to text but i could not make it back from password to text with the same button. <input type="password" name="myElement" id="pass" value="some text" /> <input name="show password" type="button" onclick="document.getElementById('pass').type = 'text';" /> any advise please Link to comment https://forums.phpfreaks.com/topic/212666-javascript-hideshow-password-field-help/ Share on other sites More sharing options...
Adam Posted September 6, 2010 Share Posted September 6, 2010 You mean to toggle the type? Try this: function toggleType() { var obj = document.getElementById('pass'); if (obj.type == 'text') { obj.type = 'password'; } else { obj.type = 'text'; } } Then call it with: onclick="toggleType();" Link to comment https://forums.phpfreaks.com/topic/212666-javascript-hideshow-password-field-help/#findComment-1107848 Share on other sites More sharing options...
dsp77 Posted September 6, 2010 Author Share Posted September 6, 2010 it works thanks Link to comment https://forums.phpfreaks.com/topic/212666-javascript-hideshow-password-field-help/#findComment-1107855 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.