如果我运行,验证只能在符号“/”上工作,如果我输入除/ didnt工作之外的其他符号。我不使用正则表达式
if(nama!==""){
var i;
var list = new Array ("/","!", "@", "#","$","%","%","^","&","*","(",")","_","+","=","-","`","~",";","<",">",".","?","[","]","{","}",",");
var llength = list.length;
for(i=0; i<llength; i++)
{
if(nama.match(list[i]))
{
alert("Full Name must not contain any number and symbol");
return false;
}
else
{
return true;
}
}
}
答案 0 :(得分:3)
if(nama.indexOf(list[i])!=-1)
{
alert("Full Name must not contain any number and symbol");
return false;
}
else
{
return true;
}
使用.indexOf