我有以下JS代码:
编辑
function validateForm() {
var IsOk = true;
var RegNumbers = (/^[0-9]+$/);
var iChars = "!@#$%^&*()+=-[]\';,/{}|\":<>?";
if (Fname == null || Fname == "") {
alert("can't be empty");
IsOk = false;
}
else if (Fname.length < 2) {
alert("the iput too short ");
IsOk = false;
}
else if (Fname != "") {
if (RegNumbers.test(Fname)) {
alert("Fname can't include numbers");
IsOk = false;
}
for (var i=0; i<Fname.length;) {
if (iChars.indexOf(Fname[i]) != -1) {
IsOk = false; alert('no special chracters pleas!');
break;
}
}
}
}
问题在于,当输入是特殊字符时,不会发出不允许输入的警告。为什么??希望得到帮助。谢谢