JS authentication password can not be empty, must contain numbers, letters, special characters, length in 8-12 bits

Source: Internet
Author: User

Tag: amp char length Other password asc long BST arc

Checkpassword = function (v) {
var numasc = 0;
var charasc = 0;
var otherasc = 0;
if (0==v.length) {
Return "Password cannot be empty";
}else if (v.length<8| |v.length>12) {
Return "Password at least 8 characters, maximum of 12 characters";
}else{
for (var i = 0; i < v.length; i++) {
var asciinumber = V.substr (i, 1). charCodeAt ();
if (asciinumber >= && asciinumber <= 57) {
NUMASC + = 1;
}
if ((Asciinumber >= && asciinumber <= 90) | | (Asciinumber >= && asciinumber <= 122)) {
CHARASC + = 1;
}
if ((Asciinumber >= && asciinumber <= 47) | | (Asciinumber >= && asciinumber <= 64) | | (Asciinumber >= && asciinumber <= 96) | | (Asciinumber >= 123 && asciinumber <= 126)) {
OTHERASC + = 1;
}
}
if (0==NUMASC) {
Return "Password must contain a number";
}else if (0==CHARASC) {
Return "Password must contain letters";
}else if (0==OTHERASC) {
Return "Password must contain special characters";
}else{
return true;
}
}
};

JS authentication password can not be empty, must contain numbers, letters, special characters, length in 8-12 bits

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.