The strength verification of JS Common password and the judgement function of uppercase and lowercase letters

Source: Internet
Author: User
Tags lowercase

The strength verification of JS Common password and the judgement function of uppercase and lowercase letters
*/

function Charmode (in) {
if (in>=65 && in <=90)//Uppercase
return 2;
if (in>=97 && in <=122)//lowercase
return 4;
Else
return 1; Digital
}
Calculates how many patterns there are in the current password
function Bittotal (num) {
modes=0;
for (i=0;i<3;i++) {
if (num & 1) modes++;
num>>>=1;
}
return modes;
}
Checkstrong function returns the strength level of the password
function Checkstrong (SPW) {
modes=0;
for (i=0;i<spw.length;i++) {
Test the category of each character and count how many patterns there are.
Modes|=charmode (Spw.charcodeat (i));
}
var btotal = bittotal (modes);
if (spw.length >=) btotal++;
Switch (btotal) {
Case 1:
Return "<table width= ' 130 ' class= ' PS tutorial wstrong ' ><tr><td bgcolor= ' #fe707e ' ><strong> weak </ Strong></td><td><span style= ' color: #666; ' > </span></td><td><span style= ' color: #666; ' > Strong </span></td></tr></table> ";
Break
Case 2:
Return "<table width= ' 130 ' class= ' Pswstrong ' ><tr><td bgcolor= ' #fcfa93 ' ><span style= ' color: #666 ;' > Weak </span></td><td bgcolor= ' #fcfa93 ' ><strong> in </strong></td><td> <span style= ' color: #666; ' > Strong </span></td></tr></table> ";
Break
Case 3:
Return "<table width= ' 130 ' class= ' Pswstrong ' ><tr><td bgcolor= ' #bdfea6 ' ><span style= ' color: #666 ;' > Weak </span></td><td bgcolor= ' #bdfea6 ' ><span style= ' color: #666; ' > </span></td><td bgcolor= ' #bdfea6 ' ><strong> strong </strong></td></tr> </table> ";
Break
Default
Return "<font color= ' #33cc00 ' > Strong </font>";
}
}

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.