Monday, January 17, 2011

Email Validation from Codebehind



if (System.Text.RegularExpressions.Regex.IsMatch(txtNewsletter.Text, "^([0-9a-zA-Z]([-.\\w]*[0-9a-zA-Z])*@([0-9a-zA-Z][-\\w]*[0-9a-zA-Z]\\.)+[a-zA-Z]{1,3})$") == false)
{
Page.RegisterStartupScript("GetType", "<script language='javascript'>alert('Please enter valid email address!')</script>'");
}

0 comments:

Post a Comment

 
Design by Free WordPress Themes | Bloggerized by Lasantha - Premium Blogger Themes | Best Wallpapers collections