Tuesday, August 18, 2009

Regular expression validator for email format code behind

If System.Text.RegularExpressions.Regex.IsMatch(TxtbEmail.Text, "^(([^<>()[\]\\.,;:\s@\""]+(\.[^<>()[\]\\.,;:\s@\""]+)*)|(\"".+\""))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$") = False Then

show error

Else

do processing

end if

No comments: