ASP.NET email validator regex

前端 未结 6 1125
走了就别回头了
走了就别回头了 2020-12-02 22:24

Does anyone know what the regex used by the email validator in ASP.NET is?

6条回答
  •  遥遥无期
    2020-12-02 23:14

    Apart from the client side validation with a Validator, I also recommend doing server side validation as well.

    bool isValidEmail(string input)
    {
        try
        {
            var email = new System.Net.Mail.MailAddress(input);
            return true;
        }
        catch
        {
            return false;
        }
    }
    

提交回复
热议问题