I tried to use text box with text mode="Email", but it only validate is the text with @ or not. I can still pass my text with ABC@ABC without any second level domain.
I still have to validate the string input by another validation/function to done this.
<asp:TextBox ID="Email" MaxLength="50" PlaceHolder="[email protected]" runat="server" textMode="Email" /> =
<br/>
<asp:RegularExpressionValidator ID="EmailFormat" runat="server" Text="Please enter a valid Email" ToolTip="Please enter a valid Email" ControlToValidate="Email" ValidationExpression="(\w)+@(\w)+.com(.(\w)+)*" ForeColor="Red" />
I think you have to try Email Validation using regular expression in ASP.Net. I have below code for you which solve your problem.
<asp:TextBox ID="txtEmailAddress" runat="server" CssClass="NormalTextBox inputText"></asp:TextBox>
<asp:RegularExpressionValidator ID="revEmailAddress" runat="server" SetFocusOnError="true"
Display="None" ControlToValidate="txtEmailAddress" resourceKey="revEmailAddress"
ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*" ValidationGroup="register"></asp:RegularExpressionValidator>
<asp:Button ID="lnkBtnRegister" runat="server" ValidationGroup="register"
CssClass="login-btn fl" CausesValidation="true" OnClick="lnkBtnRegister_Click" />
<asp:ValidationSummary ID="valsumRegister" resourceKey="valsumRegister" runat="server"
ShowSummary="false" ShowMessageBox="true" ValidationGroup="register" HeaderText="Please Provide..." />
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With