Net-informations.com
SiteMap  | About    

Email Address Validation

An email address is a string of a subset of ASCII characters separated into two parts by an @ symbol . The part before the @ sign is the local part of the address, and the part after the @ sign is a domain name to which the email message will be sent .

email-validation

The above email address feedback is the local part and net-informations.com is the domain name to which the email message will be sent .

Here we are going to implement a regular expression pattern to validate email address. A regular expression is a pattern describing a certain amount of text. The .NET Framework regular expression classes are part of the base class library and can be used with any language or tool that targets the common language runtime, including ASP.NET and Visual Studio .NET. Regex.IsMatch Method (String, String) - indicates whether the specified regular expression finds a match in the specified input string.

  Regex.IsMatch("feedback@net-informations.com", pattern)

The pattern parameter consists of various regular expression language elements that symbolically describe the string to match pattern . The following ASP.NET program shows how to validate an email address with the help of regular expressions.

Default.aspx

  

<!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 id="Head1" runat="server">
<title>Untitled Page</title>
</head>
<body>
	<form id="form1" runat="server">
	<div>
		<asp:Label ID="Label1" runat="server" Text="Enter e-mail address"></asp:Label>
		<br />
		<asp:TextBox ID="TextBox1" runat="server" Width="284px"></asp:TextBox>
		<br />
		<br />
		<asp:Button ID="Button1" runat="server" onclick="Button1_Click1"
		Text="Validate" Width="80px" />
		&nbsp;
		<asp:Label ID="Label2" runat="server" Text="Label"></asp:Label>
	</div>
	</form>
</body>
</html>


Click the following links to see full source code

C# Source Code
VB.NET Source Code
default.aspx.cs
default.aspx.vb






net-informations.com (C) 2017    Founded by raps mk
All Rights Reserved. All other trademarks are property of their respective owners.