//判断是否是数字和字母
function isregname()
{
var checkOK = "0123456789-_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
var checkStr = document.getElementById("name").value;
var allValid = true;
var decPoints = 0;
for (i = 0; i < checkStr.length; i++)
{
ch = checkStr.charAt(i);
for (j = 0; j < checkOK.length; j++)
if (ch == checkOK.charAt(j))
break;
if (j == checkOK.length)
{
allValid = false;
break;
}
}
return (allValid)
}
//判断是否大于等于8个字符
function str8()
{
var checkStr = document.getElementById("name").value;
if(checkStr.length >= 8)
{
return true;
}
else
{
return false;
}
}
//验证弱口令
function adv()
{
if(!(isregname())){
alert("密码只能是英文字母或数字");
return(false);
}
if(str8() == false)
{
alert("密码长度不能小于8个字符")
return(false);
}
}
判断数字字符8位
最新推荐文章于 2021-03-01 14:56:33 发布