How to display prompt information in the password form in js

Source: Internet
Author: User

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]

Related Article

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.