Validating Email Address
-
Hi, How can I validate the email Address in a textbox with multiple information. The same validation in yahoo when you add email add, if email add is not correct there is an error message.
Sample. dvd@yahoo.com; exevl@hotmail.com -- > correct (semicolon) dvd@yahoo.com exevl@hotmail.com -- > correct (space) James borlan [ James@yahoo.com] -- > incorrect james@yahoo.com Donald@yahoo.com [All email] - incorrect
Thanks DabuskolDabsukol
-
Hi, How can I validate the email Address in a textbox with multiple information. The same validation in yahoo when you add email add, if email add is not correct there is an error message.
Sample. dvd@yahoo.com; exevl@hotmail.com -- > correct (semicolon) dvd@yahoo.com exevl@hotmail.com -- > correct (space) James borlan [ James@yahoo.com] -- > incorrect james@yahoo.com Donald@yahoo.com [All email] - incorrect
Thanks DabuskolDabsukol
-
Hi, How can I validate the email Address in a textbox with multiple information. The same validation in yahoo when you add email add, if email add is not correct there is an error message.
Sample. dvd@yahoo.com; exevl@hotmail.com -- > correct (semicolon) dvd@yahoo.com exevl@hotmail.com -- > correct (space) James borlan [ James@yahoo.com] -- > incorrect james@yahoo.com Donald@yahoo.com [All email] - incorrect
Thanks DabuskolDabsukol
http://regexlib.com/Search.aspx?k=ip+address code below matchs ip string RegString = @"^(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9])\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[0-9])$"; Regex RegObj = new Regex(RegString); if (!RegObj.IsMatch(ipString)) MessageBox.Show("error", MessageBoxButtons.OK, MessageBoxIcon.Error);
-
Hi, How can I validate the email Address in a textbox with multiple information. The same validation in yahoo when you add email add, if email add is not correct there is an error message.
Sample. dvd@yahoo.com; exevl@hotmail.com -- > correct (semicolon) dvd@yahoo.com exevl@hotmail.com -- > correct (space) James borlan [ James@yahoo.com] -- > incorrect james@yahoo.com Donald@yahoo.com [All email] - incorrect
Thanks DabuskolDabsukol
This will match the pattern of an email address using a regex expression:
public bool EmailValid(string email) { string _expression = @"^([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}" + @"\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\" + @".)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$"; return System.Text.RegularExpressions.Regex.IsMatch( email, _expression ); }
Hope this helps
Regards Wayne Phipps ____________ Time is the greatest teacher... unfortunately, it kills all of its students View my Blog
-
Hi, How can I validate the email Address in a textbox with multiple information. The same validation in yahoo when you add email add, if email add is not correct there is an error message.
Sample. dvd@yahoo.com; exevl@hotmail.com -- > correct (semicolon) dvd@yahoo.com exevl@hotmail.com -- > correct (space) James borlan [ James@yahoo.com] -- > incorrect james@yahoo.com Donald@yahoo.com [All email] - incorrect
Thanks DabuskolDabsukol
See this thread: http://www.codeproject.com/script/comments/forums.asp?forumid=1649&Page=4&userid=157870&mode=all&select=1800655&df=100&fr=12754.5#xx1800655xx[^] The bottom line is that regular expressions will catch most of the more commonly used forms for email addresses, but not all of them. It all depends on how strictly you want to follow the RFC specs. You can also use the MailAddress[^] class in .NET 2.0, which works for almost all of the valid RFC formats (but there are a few of the more complicated and seldom used formats that it also doesn't get right).
----------------------------- In just two days, tomorrow will be yesterday.