JavaScript过滤特殊字符 1.设计实例 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta h
function stripscript(s) { var pattern = new RegExp("[`~!@#$^&*()=|{}':;',\\[\\].<>/?~!@#¥--&*()--|{}[]'::""'.,.?%]") var rs = ""; for (var i = 0; i < s.length; i++) { rs = rs+s.substr
for循环遍历特殊字符和用户输入字符,然后做比较,返回结果. <script type="text/javascript"> var name = prompt("请输入用户名"); function ifname(value) { var astr = ["~","!","@","#","$","%","^",&q