Javascript + Div password security verification

Source: Internet
Author: User

Complete password security verificationCodeIf there is a better person, I hope to reply to me:

<! Doctype HTML public "-// W3C // dtd xhtml 1.0 transitional // en" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<HTML xmlns = "http://www.w3.org/1999/xhtml">
<Head>
<Title> password security verification </title>
<Script language = JavaScript>
Function hiddenlayer ()
{
Layer1.style. Visibility = "hidden ";
Layer2.style. Visibility = "hidden ";
Layer3.style. Visibility = "hidden ";
}
Function checkpasswordlevel (o ){
VaR n = 0;
If (/\ D/. Test (O. Value) n ++; // Contains numbers
If (/[A-Z]/. Test (O. Value) n ++; // Contains lowercase letters
If (/[A-Z]/. Test (O. Value) n ++; // Contains uppercase letters
If (/\ W/. Test (O. Value) n ++; // Contains other characters
If (O. value. Length <5) n = 1; // The length is less than 5 Characters
If (n = 1)
{
Layer1.style. Visibility = "visible ";
Layer2.style. Visibility = "hidden ";
Layer3.style. Visibility = "hidden ";
}
Else if (n = 2)
{
Layer1.style. Visibility = "hidden ";
Layer2.style. Visibility = "visible ";
Layer3.style. Visibility = "hidden ";
}
Else if (n> = 3)
{
Layer1.style. Visibility = "hidden ";
Layer2.style. Visibility = "hidden ";
Layer3.style. Visibility = "visible ";
}

}
</SCRIPT>
</Head>
<Body Onload = "hiddenlayer ()">

Password: <input id = "password1" type = "password" Onkeyup = "checkpasswordlevel (this )"/ > <Br/>
<Div id = "layer1" style = "Z-index: 101; left: 57px; width: 150px; position: absolute;
Top: 39px; Height: 20px; Background-color: # ff0000 ">
<Span style = "color: # ffffff"> <strong> & nbsp; insecure </strong> </span> </div>
<Div id = "Layer2" style = "Z-index: 102; left: 57px; width: 150px; position: absolute;
Top: 39px; Height: 20px; Background-color: # ffcc33 ">
<Span style = "color: # ffffff"> <strong> & nbsp; normal </strong> </span> </div>
<Div id = "layer3" style = "Z-index: 102; left: 57px; width: 150px; position: absolute;
Top: 39px; Height: 20px; Background-color: #006600 ">
<Span style = "color: # ffffff"> <strong> & nbsp; very Secure </strong> </span> </div>
</Body>
</Html>

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.