|
- function validPsw() {
- var password = $(".password").val();
- var num = 0;
- var number = 0 ;
- var letter = 0 ;
- var bigLetter = 0 ;
- var chars = 0 ;
-
- if (password.search(/[0-9]/) != -1) {
- num += 1;
- number =1;
- }
- if (password.search(/[A-Z]/) != -1) {
- num += 1;
- bigLetter = 1 ;
- }
- if (password.search(/[a-z]/) != -1) {
- num += 1;
- letter = 1 ;
- }
- if (password.search(/[^A-Za-z0-9]/) != -1) {
- num += 1;
- chars = 1 ;
- }
- if (num >= 2 && (password.length >= 6 && password.length <= 16)) {
- $(".pswSpan").html("");
- $(".password").css("border","#B0B0B0 solid 1px");
- }else if(password.length < 6 || password.length > 16){
- $(".pswSpan").html("密码由6-16个字符组成!");
- $(".password").css("border","#B35D5D solid 1px");
- }else if(num == 1){
- if(number==1){
- $(".pswSpan").html("不能全为数字!");
- }
- if(letter==1){
- $(".pswSpan").html("不能全为字母!");
- }
- if(bigLetter==1){
- $(".pswSpan").html("不能全为字母!");
- }
- if(chars==1){
- $(".pswSpan").html("不能全为字符!");
- }
- $(".password").css("border","#B35D5D solid 1px");
- }
- }
复制代码 |
|