The classic someone wants this code, considering the password input content will display as the * number, so to find a way to solve the problem. Originally want to use setattribute dynamic Modify type attribute to achieve results, and then FF Test success, but did not expect setattribute on the Type property modification in IE invalid. Finally, a background image was used to solve this problem. That is, set a background picture for password, the picture text is the hint information
For example: The background picture is not displayed when the mouse is placed.
The code is as follows:
<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dt D "> <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> <script language= "JavaScript" > function chgform (ID) { if (document.getElementById (ID). value== "Password length must be between 3-18 digits") document.getElementById (ID). value= ""; document.getElementById (ID). setattribute ("type", "password"); function Chkform (ID) {if (document.getElementById (ID). value.length==0) {document.getElementById (ID). set Attribute ("type", "text"); document.getElementById (ID). value= "Password length must be between 3-18 digits"; }} function Chkformpic (ID) {if (docuMent.getelementbyid (ID). value.length==0) {document.getElementById (id). style.background= ' URL (/upload/20070819124 037566.gif) No-repeat '; } </script> Name: <input type= "text" id= "username" value= "name length maximum 16 characters" onfocus= "This.select ()"/> Dynamically modifying input's type attribute (valid only under FF): Password: <input type= "text" id= "password" onmouseover= "chgform (' password ')" value= "Password length must be Must be "onmouseout=" chkform (' password ') in between 3-18 digits/> picture hint (valid under ff/ie): Password: <input type= "password" id= "P1" Onmouseov Er= "this.style.background=" "onmouseout=" chkformpic (' P1 ') "/> </body> </ptml>
[Ctrl + A All SELECT Note: If the need to introduce external JS need to refresh to perform]