I have an input field that is by default set to type="text" so that the word Password can be displayed in it. I have the following to change it to a password field when the user selects it, which works fine in any browser I have tried except Internet Explorer.
onfocus="this.type='password';"
How would I go about making this work in IE?
I have an input field that is by default set to type="text" so that the word Password can be displayed in it. I have the following to change it to a password field when the user selects it, which works fine in any browser I have tried except Internet Explorer.
onfocus="this.type='password';"
How would I go about making this work in IE?
Share Improve this question asked Aug 22, 2009 at 14:45 James SimpsonJames Simpson 13.7k26 gold badges85 silver badges111 bronze badges 3- That's why advise against never using I.E again. – jay_t55 Commented Aug 22, 2009 at 15:28
- yeah, great thought but 60% of your users have other ideas...! – redsquare Commented Aug 22, 2009 at 15:33
- Yeah, true! :-) I don't mind developing for Internet Explorer, although I do wish it was easier lol. – jay_t55 Commented Aug 22, 2009 at 15:53
3 Answers
Reset to default 6IE does not like to change the type of an element dynamically, one solution might be to replace the element entirely. However I would suggest you just use a input type password so any non js users would still get the same functionality and live without the watermark.
What effect are you trying to achieve? Do you want the initial password to be visible, but when they go to enter a new one, it's obscured? If so, you might want to simply replace the element with a password input, copying the value.
You are better off using a <label> with the text "password" rather than displaying it inside the control itself. You can make the label appear like it is inside the textbox using css. A List Apart has a good article on this sort of thing: http://www.alistapart./articles/makingpactformsmoreaccessible/
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744221270a4563793.html
评论列表(0条)