how to give email validation to textbox in gridview in asp.net
I Have gridview and in that i have textbox for email and i want to give email validation to that textbox on save
how to give email validation to textbox in gridview in asp.net
I Have gridview and in that i have textbox for email and i want to give email validation to that textbox on save
Regex sample
bool isEmail = Regex.IsMatch(emailString, @"\A(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?)\Z", RegexOptions.IgnoreCase);
or
.Net.Mail sample
bool IsValidEmail(string email)
{
try {
var mail = new System.Net.Mail.MailAddress(email);
return true;
}
catch {
return false;
}
}