开发者

Why would Internet explorer not allow changing the type of an input?

开发者 https://www.devze.com 2023-03-02 08:01 出处:网络
I have written a modern login form where \'Username\' is written 开发者_如何学Pythonin one field, but is grey, when you click it, it vanishes and also turns the text black, I also have a \'Password\'

I have written a modern login form where 'Username' is written 开发者_如何学Pythonin one field, but is grey, when you click it, it vanishes and also turns the text black, I also have a 'Password' on that starts as a text input, but when you click on it, it is supposed to change to a password type, but it remains text. This seams to only appear on IE8? why and is there a work around?

onFocus='if (this.value == "Password"){ this.value = ""; this.type = "password";}'


Internet Explorer's DOM implementation wasn't designed to handle dynamically changing INPUT types. See http://msdn.microsoft.com/en-us/library/ms534700.aspx.

As a workaround, you can have a hidden password field and then switch visibility between the text box and the password field.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号