有人可以帮助我将*,&,(,)添加到以下正则表达式中吗?
var r=/^[\sa-zA-Z0-9'\.,-]+$/;
if(!(r.test(search_key))){
alert("Sorry, you have entered invalid characters, please try again.");
return false;
}
if(search_key =="Keyword(s)"){
document.getElementById("field1").value = "";
}
if(search_city =="City, State or Zip"){
document.getElementById("GH_search_field2").value = "";
}
答案 0 :(得分:2)
var r=/^[\sa-zA-Z0-9'.,*&()-]+$/;
最后-
很重要,尽管你也可以用反斜杠将其转义并放在任何地方。