特殊字符及邮箱校验

  //只允许汉字、英文字母、数字、下划线!
        else if (!txtName.match(/^[u4E00-u9FA5a-zA-Z0-9_]{0,}$/)) {//.match(/^[u4E00-u9FA5a-zA-Z0-9_]{3,20}$/) //{3,20}$表示是长度3-20
            $("#prompt_txtName").text("只允许汉字、英文字母、数字、下划线!");
        }
        //邮箱验证
        else if (!txtName.match(/^w+((-w+)|(.w+))*@[A-Za-z0-9]+((.|-)[A-Za-z0-9]+)*.[A-Za-z0-9]+$/)) {
            $("#prompt_txtName").text("请输入正确的邮箱格式!");
        }

原文地址:https://www.cnblogs.com/xtreme/p/4463100.html