PDA

View Full Version : Unable to change the type attribute of an input field in Internet Explorer



googelybear
16 Oct 2009, 1:52 AM
The following attempt to change the type attribute of an input element from text to password creates a very nice exception in IE (it works fine in firefox and safari):

com.google.gwt.dom.client.Element = Document.get().getElementById("password-input"); // fetch the iput element
passwordElement.setAttribute("type", "password");

2009-10-16 02:36:22,437 [FATAL] Uncaught Exception:
com.google.gwt.core.client.JavaScriptException:
(Error): This command is not supported.
number: -2147221248
description: This command is not supported.Does anyone have an idea why this is happening? (I'm aware that there is a setPassword method on the TextField class but I cannot use that).

edit: Just found out that great Microsoft decided to make the "type" attribute on an input element read-only - once it's set it cannot be changed later on (thank you very much!) Reference: http://msdn.microsoft.com/en-us/library/ms534700%28VS.85%29.aspx