jQuery使用正则判断是否含有非法字符

if(/[@#$%^&*]+/gi.test($("#user_api_register_form").find("input[name='user_name']").val()))
{
$.showErr("用户名含有非法字符",function(){    
$("#user_api_register_form").find("input[name='user_name']").focus();

});
return false;
}
原文地址:https://www.cnblogs.com/xuzhengzong/p/6866276.html