如何写正则表达式让字符串中不能有2a3d几个字符中的任意一个 var s = "2a3d";var reg = new RegExp("["+ s +"]", "g");var str = "weyusa";alert(reg.test(str)); 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 <script>var str="hello2";if(/[2a3d]/g.test(str))alert('字符串包含非法字符');elsealert('字符串合格');</script> <html><head><script language="JavaScript" >function checkOtherChar(str,errmsg) { for(var loop_index=0; loop_index<str.length; loop_index++) { if(str.charAt(loop_index) == '2' ||str.charAt(loop_index) == 'a' ||str.charAt(loop_index) == '3' ||str.charAt(loop_index) == 'd' ) { alert(errmsg); return false; } }//end of for(loop_index) return true; } checkOtherChar('1111',"error"); </script></head><body><form name="x" ></form></body></html> 庖丁解牛——由企业级应用与网站的疑惑想到的~~~ 30分求一段可以让IE窗口标题高亮闪动的代码 求一个模拟的select代码,或者思路 关于struts的问题,急!!!!! js提交表单返回的问题 如何用 Javascript 自动查找替换网页中的特定字符 怎样得到div的名字 在网页中如何动态展示数据曲线? 急:如何用javascript判断网络资源是否存在 在线等着回答 帮忙看看这个问题急!!! 不难的问题. 时间连动问题.
var str="hello2";
if(/[2a3d]/g.test(str))
alert('字符串包含非法字符');
else
alert('字符串合格');</script>
<html>
<head>
<script language="JavaScript" >
function checkOtherChar(str,errmsg) {
for(var loop_index=0; loop_index<str.length; loop_index++)
{
if(str.charAt(loop_index) == '2'
||str.charAt(loop_index) == 'a'
||str.charAt(loop_index) == '3'
||str.charAt(loop_index) == 'd'
)
{
alert(errmsg);
return false;
}
}//end of for(loop_index)
return true;
}
checkOtherChar('1111',"error");
</script>
</head>
<body>
<form name="x" >
</form></body>
</html>