The following javascript snippet will change the type of an INPUT, for instance from text to password. It’s being used to allow users to display their password on-screen when typing it in:
document.save_form.password_confirm.type= 'text';
...
document.save_form.password_confirm.type= 'password';
This works great in FF/Chrome but in IE6/7/8 I’m getting a “This command is not supported” error message.
Type is read-only in Internet Explorer (at least 6, anyway), so it’s just not directly possible. As a workaround, I’ve had a hidden input field of the type I wanted, then when I need to switch the type, hid the old one and made the other one visible. Not as clean, but unfortunately just changing the type as far as I know isn’t possible.
An alternative method would be to use the JavaScript DOM to replace the field with the replaceChild function of a node.