ASP.NET email validator regex

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

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

6条回答
  •  猫巷女王i
    2020-12-02 22:59

    We can use RegularExpressionValidator to validate email address format. You need to specify the regular expression in ValidationExpression property of RegularExpressionValidator. So it will look like

     
    

    Also in event handler of button or link you need to check !Page.IsValid. Check sample code here : sample code

    Also if you don't want to use RegularExpressionValidator you can write simple validate method and in that method usinf RegEx class of System.Text.RegularExpressions namespace.

    Check example:

    example

提交回复
热议问题