sravanti rachala
I want to create a text box where in i want to enter email address only. How to do that ?
By sravanti rachala in ASP.NET on Aug 06 2011
  • rakesh g
    Sep, 2011 13

    <asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server"
                ControlToValidate="TBMailId" ErrorMessage="check ur mail id"
                style="z-index: 1; left: 452px; top: 549px; position: absolute"
                ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"></asp:RegularExpressionValidator>

    • 0
  • chaithanya chowdary
    Aug, 2011 12

    Hi

    In your  C# Web Application,  In the aspx page  Use RegularExpressionValidator

    <asp:TextBox ID="TextBoxEmail" runat="server"><asp:TextBox>

    <asp:RegularExpressionValidator ID="RegularExpressionValidatorTextBoxEmail" ControlToValidate="TextBoxEmail"

    runat="server" ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"

    ErrorMessage="Enter valid Email"></asp:RegularExpressionValidator>

     

     

    • 0
  • DMR Santosh
    Aug, 2011 11

    Hi Sravanti,
    You can try the below code...
    string  Email_Expression;
            private void button1_Click(object sender, EventArgs e)
            {
                Email_Expression ="^[a-zA-Z][\\w\\.-]{2,28}[a-zA-Z0-9]@[a-zA-Z0-9][\\w\\.-]*[a-zA-Z0-9]\\.[a-zA-Z][a-zA-Z\\.]*[a-zA-Z]$" ;
                if (textBox1.Text != null)
                {
                    if (Regex.IsMatch(textBox1.Text, Email_Expression))
                        MessageBox.Show("You have entered Correct Email ID");
                    else
                        MessageBox.Show("Please Enter Email Correctly");
                }
            }

    Thanks & Regards
    Santosh D.M.R

    • 0
  • Ayyappa K
    Aug, 2011 10

    Hey You can use this code 


    /^[a-zA-Z0-9._-]+@[a-zA-Z0-9-.]+\.[a-zA-Z]{2,4}$/;

    • 0
  • Neeraj Pandey
    Aug, 2011 10

    In C# Web Application Use RegularExpressionValidator


    Select Property and Change

    ControlToValidate="textboxID" 
      ValidationExpression="^[a-zA-Z][\w\.-]{2,28}[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$" 
                ErrorMessage="Please Enter  Email ID"

    • 0


Most Popular Job Functions


MOST LIKED QUESTIONS