JS验证输入的字符是否为重复或连续字母数字字符

function CheckPass(strText) {
strText = strText.toUpperCase();
strText = strText.replace(/[ ]/g, "");
var str1 = "01234567890";
var str2 = "09876543210";
var str3 = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
var str4 = "ZYXWVUTSRQPONMLKJIHGFEDCBA";
//检查是否为连续的字符
if (str1.indexOf(strText) > -1 || str2.indexOf(strText) > -1 || str3.indexOf(strText) > -1 || str4.indexOf(strText) > -1) {
return false
}
var strlength = strText.length;
//检查是否为重复的字符
for (i = 0; i < strlength-1; i++) {
var v1=strText.charAt(i);
var v2=strText.charAt(i+1);
if (v1 != v2) {
return true;
}
}
return false;
}

转载于:https://www.cnblogs.com/Iven-zhang/archive/2013/04/18/3029210.html

你可能感兴趣的:(JS验证输入的字符是否为重复或连续字母数字字符)