JS in the password form to display the message of the solution _ form effects

Source: Internet
Author: User
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]

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.