密码大写小写数字重复

时间:2013-11-18 10:05:54
【文件属性】:
文件名称:密码大写小写数字重复
文件大小:2KB
文件格式:TXT
更新时间:2013-11-18 10:05:54
大写 小写 数字 重复 function validate(str){ var illegalChars = ['*','-'];//指定的特殊字符写在这个数组里面,个数不限。 str = str.value; var numberCount = 0; var upperCaseCount = 0; var lowerCaseCount = 0; var otherCharCount = 0; var numberIndex = 0; var upperCaseIndex = 0; var lowerCaseIndex = 0; var otherCharIndex = 0; var temp; for (var i = 0; i < str.length; i++) { temp = str.charAt(i); for(var j = 0; j < illegalChars.length; j++){ if(temp == illegalChars[j]){ return false; } } temp = temp.charCodeAt(); if (temp >= 48 && temp <= 57) { numberIndex = i; numberCount++; }else if(temp >= 65 && temp <= 90){ upperCaseIndex = i; upperCaseCount++; }else if(temp >= 97 && temp <= 122){ lowerCaseIndex = i; lowerCaseCount++; }else{ otherCharIndex = i; otherCharCount++; } } if (numberCount == 0 || (numberCount == 1 && (numberIndex == 0 || numberIndex == str.length-1 ))) { return false; } if (upperCaseCount == 0 || (upperCaseCount == 1 && (upperCaseIndex == 0 || upperCaseIndex == str.length-1 ))) { return false; } if (lowerCaseCount == 0 || (lowerCaseCount == 1 && (lowerCaseIndex == 0 || lowerCaseIndex == str.length-1 ))) { return false; } if (otherCharCount == 0 || (otherCharCount == 1 && (otherCharIndex == 0 || otherCharIndex == str.length-1 ))) { return false; } var result; for(var i=0;i 立即下载

网友评论