Hi friends, in
this article I will explain about RegularExpressionValidator for Email ID in
ASP.NET or ASP.NET RegularExpressionValidator
example.
The
RegularExpressionValidator control is used to check that an input value matches
a specified pattern or not.
I will explain
this with small example.
Take one new web
site(file--- new website--- give name o the website).
Take one webpage
name it as resularexp.aspx and drag and drop the RegularExpressionValidator as
shown in the below figure.
And write the following
code in the .aspx source file.
<%@ Page Language="VB"
AutoEventWireup="false"
CodeFile="regularexp.aspx.vb"
Inherits="regularexp"
%>
<!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>RegularExpressionValidator for Email ID</title>
</head>
<body>
<form id="form1"
runat="server">
<div>
<h1 style="color:Green
">RegularExpressionValidator for Email ID</h1>
Enter Email Adress:<asp:TextBox ID="Email" runat="server" Width="240px"></asp:TextBox>
<asp:RegularExpressionValidator
ID="RegularExpressionValidator1"
runat="server"
ErrorMessage="Email missed @ or ','.Pls Check once and Enter
Valid Email ID"
ValidationGroup="rgSubmit"
ControlToValidate="Email"
CssClass="requiredFieldValidateStyle"
ForeColor="Red"
ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*">
</asp:RegularExpressionValidator>
</div>
</form>
</body>
</html>
|
In the above web
page.I put the code for cheching the email address.It checks only @ and ‘,’ is
there or not.If either @ or ‘,’ miss it
will raise the error Email missed @ or ','.Pls Check once and Enter Valid Email ID .Run the code. It will like below .if
you don’t enter valid email address it will shown like below figure.
CompareValidator in ASP.NET
CustomValidator Control, How to Validate with a Custom Function for ASP.NET Server Controls, ASP.NET CustomValidator Control.
RegularExpressionValidator for Email ID in ASP.NET or ASP.NET RegularExpressionValidator example.
ValidationSummary in ASP.NET
I think you like my blog Aspdotnet-Kishore why are waiting following me on facebook fan page Aspdotnet-Kishore
No comments:
Post a Comment