做个参考
<script language=javascript>
function check()
{
var keyword;
var word;
keyword="'|%|&|*";
word=document.form1.t1.value;
key=keyword.split("|");
for(var i=0;i<key.length;i++)
{
for(var j=0;j<word.length;j++)
{
if(word.substring(j,j+1)==key[i]){alert("输入内容不符合规范,请重新输
入!");return false;}
}
}
return true;
}
</script>
<form name=form1>
<input type=text name=t1 id=t1>
<input type=submit name=s1 value="提交" onclick="return check();">
</form>