How to validate email address for specified domain name using regular expression in asp.net
In this article, we will protect to textbox to take
the gmail, yahoo and Hotmail email id .Many time we need to protect the
specified the domain name to enter . in this example .we can choose the all
email id address rather than gmail, yahoo and Hotmail .for this:- we have taken the asp.net regular expression validator to validate this code just using
the below code:-
ValidationExpression="^([\w-\.]+@(?!gmail.com)(?!yahoo.com)(?!hotmail.com)([\w-]+\.)+[\w-]{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: 600px">
<legend><strong>Protect
email address for specified domain name(gmail, yahoo and hotmail) </strong></legend>
<br />
<strong>Email
Address</strong>
<asp:TextBox ID="txtemail" runat="server" Width="200px"></asp:TextBox>
<asp:RegularExpressionValidator ID="REVemail" runat="server"
ControlToValidate="txtemail" Display="Dynamic"
ErrorMessage="Please enter the valid email" ForeColor="Red"
ValidationExpression="^([\w-\.]+@(?!gmail.com)(?!yahoo.com)(?!hotmail.com)([\w-]+\.)+[\w-]{2,4})?$"></asp:RegularExpressionValidator>
</fieldset>
</div>
</form>
</body>
</html>
Output:-
How to validate email address for specified domain name using regular expression in asp.net
Reviewed by NEERAJ SRIVASTAVA
on
8:03:00 PM
Rating:
nice
ReplyDeleteKeeping these entire in mind, the company' connoisseurs had structured the immediate client service that is offered on-line. that they had meant net|the online|the net} page and web forum wherever the shoppers area unit mitigated off their emailing problems among some minutes' time. http://800support.net/yahoo-support/how-to-contact-yahoo/
ReplyDeleteA very Impressive and detailed post. Thanks for sharing such a wonderful and important information.
ReplyDeleteFor more info how to fix yahoo problems visit us @ Visit here