How to validate case-sensitive email using regular expression using asp.net c#

In this article, I will show you how to validate case sensitive email using asp.net validator control. I have used regular expression validator to make it. I have just write the below expression to validate the textbox.
ValidationExpression="^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4})$">


Design:-


Source code:-
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="emailvalidation.aspx.cs"
    Inherits="emailvalidation" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <fieldset style="width: 500px">
            <legend><strong>validate case-sensitive email address</strong></legend>
            <br />
            <strong>Email Address</strong>
            <asp:TextBox ID="txtemail" runat="server" Width="200px"></asp:TextBox>
            <asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server"
                ControlToValidate="txtemail" Display="Dynamic"
                ErrorMessage="Please enter the valid email" ForeColor="Red"
                ValidationExpression="^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4})$"></asp:RegularExpressionValidator>
        </fieldset>
    </div>
    </form>
</body>
</html>


Output:-   
How to validate case-sensitive email using regular expression using asp.net c# How to validate case-sensitive email using regular expression using asp.net c# Reviewed by NEERAJ SRIVASTAVA on 7:55:00 PM Rating: 5

No comments:

Powered by Blogger.