This code is required by a typical user. Considering that the entered content in the password will be displayed as the * number, you need to solve the * problem. When I first tried to use setAttribute to dynamically modify the type attribute to achieve the effect, and then ff the test was successful, but I did not expect that the setAttribute modification to the type attribute would be invalid in ie. The background image is used to solve this problem. That is, set a background image for password, and the image text is the prompt information.
For example: ,
When the mouse is placed, the background image is not displayed.
The Code is as follows:
<! DOCTYPE html PUBLIC "-// W3C // dtd xhtml 1.0 Transitional // EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <ptml xmlns = "http://www.w3.org/1999/xhtml" xml: lang = "en" lang = "en"> <pead> <title> </title> <style type = "text/css"> * {margin: 0px; padding: 0px; font-size: 12px;} input {width: 150px; height: 20px; line-height: 20px; border: 1px solid # ccc ;} </style> </pead> <body> name: <input type = "text" id = "username" value = "name cannot exceed 16 characters" onfocus = "this. select () "/> dynamically modify the type attribute of input (only valid under ff): password: <input type = "text" id = "password" onmouseover = "chgForm ('Password ') "value =" the password must be 3-18 characters long. "onmouseout =" chkForm ('Password') "/> image prompt (valid in ff/ie): password: <input type = "password" id = "p1" onmouseover = "this. style. background = ''" style = 'background: url (/upload/20070819124037566.gif) no-repeat 'onmouseout = "chkFormpic ('p1')"/> </body> </ptml>
[Ctrl + A select all Note: If you need to introduce external Js, You need to refresh it to execute]