Email Validation by Javascript

function EmailCheck()
{
var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
var str =document.getElementById('<%= TxtTo.ClientID %>').value;

if(reg.test(str) == false)
{
alert('Invalid Email Address');
document.getElementById('<%= TxtTo.ClientID %>').focus();
}
}

Comments

Popular posts from this blog

Page Life Cycle in ASP.NET

MVC Request Execution Stages - Life Cycle

SQL Server 2005 with XML Parameters

Polymorphism in C#

LINQ - C# Programming

Abstract Class and An Interface

Differences between a Structure and Class

Variable Value in Top Statement

Auto Refresh .aspx page - ASP.NET