javascript正则验证特殊字符过滤
<script type="text/javascript">
$("#search").click(function(){
var name = $("#title").val();
var regEx = new RegExp(/^(([^\^\.<>%&',;=?$"':#@!~\]\[{}\\/`\|])*)$/);
var result = name.match(regEx);
if (result == null) {
$("#tip").empty();
$("#tip").append("<font color='red'>输入非法,包含特殊字符</font>");
return false;
}else{
$("#tip").empty();
document.forms[0].submit();
}
});
</script>
<table width="90%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td class="tdtxt_rr" width="8%">标题:</td>
<td width="32%">
<s:textfield name="project.project_name" id="title"/>
</td>
<td width="40%" id="tip">
</td>
<td width="20%">
<a id="search" href="#" class="btn_search"><img src="${ctx}/common/images/btn_search.gif" align="absmiddle" /></a>
</td>
</tr>
</table>