Email address validation
-
Hi, I am working on a desktop application using VB.NET. On a form, ihave data tobe entered....I have done all the other validations for e.g. numeric and decimal validations. I want to validate the textbox in which email address is entered.... can any1 suggest me any link to the email address validation code? Since it is a windows application,i cant use javascript for it. Thanks Riz
-
Hi, I am working on a desktop application using VB.NET. On a form, ihave data tobe entered....I have done all the other validations for e.g. numeric and decimal validations. I want to validate the textbox in which email address is entered.... can any1 suggest me any link to the email address validation code? Since it is a windows application,i cant use javascript for it. Thanks Riz
javascript has regex, so does .NET. Just use a regular expression.
Christian Graus - C++ MVP 'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert
-
Hi, I am working on a desktop application using VB.NET. On a form, ihave data tobe entered....I have done all the other validations for e.g. numeric and decimal validations. I want to validate the textbox in which email address is entered.... can any1 suggest me any link to the email address validation code? Since it is a windows application,i cant use javascript for it. Thanks Riz
hi that is the code in JS switch case in acse of more validating fields u can add here check that if any prob kindly notify var mEmailAddress = ''; cInvalidEmailAddress = "Invalid email address in " cInvalidEmailAddress = "Invalid email address in " switch(cType) { case 'email' : var cVal; cVal=checkRequired(obj); if(cVal!=1 && cVal!=2) { mReqdFields = mReqdFields + cVal + '\n'; } else if(cVal==2) { if(!validateEmail(obj)) mEmailAddress = mEmailAddress + obj.caption + '\n'; } break; } if (mEmailAddress != '') ErrStr = ErrStr + cInvalidEmailAddress + mEmailAddress + '\n';
SP -- Bugs can neither be created nor be removed from software by a developer. They can only be converted from one form to another. The total number of bugs in the software always remain constant.
-
javascript has regex, so does .NET. Just use a regular expression.
Christian Graus - C++ MVP 'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert
-
hi that is the code in JS switch case in acse of more validating fields u can add here check that if any prob kindly notify var mEmailAddress = ''; cInvalidEmailAddress = "Invalid email address in " cInvalidEmailAddress = "Invalid email address in " switch(cType) { case 'email' : var cVal; cVal=checkRequired(obj); if(cVal!=1 && cVal!=2) { mReqdFields = mReqdFields + cVal + '\n'; } else if(cVal==2) { if(!validateEmail(obj)) mEmailAddress = mEmailAddress + obj.caption + '\n'; } break; } if (mEmailAddress != '') ErrStr = ErrStr + cInvalidEmailAddress + mEmailAddress + '\n';
SP -- Bugs can neither be created nor be removed from software by a developer. They can only be converted from one form to another. The total number of bugs in the software always remain constant.
-
Hi, I dont want to use javascript coz it is not a web application. Since it is a windows application i want to find a code which will validate the characters entered using ASCII codes. Waiting for ur reply. Thanks Riz
This should do it :)
Function IsValidEmail(strIn As String) As Boolean
' Return true if strIn is in valid e-mail format.
Return Regex.IsMatch(strIn, "^([\w-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$")
End FunctionGod bless msdn...
-
This should do it :)
Function IsValidEmail(strIn As String) As Boolean
' Return true if strIn is in valid e-mail format.
Return Regex.IsMatch(strIn, "^([\w-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$")
End FunctionGod bless msdn...
-
This should do it :)
Function IsValidEmail(strIn As String) As Boolean
' Return true if strIn is in valid e-mail format.
Return Regex.IsMatch(strIn, "^([\w-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$")
End FunctionGod bless msdn...
@kulazfuk thanks that helped me too..
-
Hi, I am working on a desktop application using VB.NET. On a form, ihave data tobe entered....I have done all the other validations for e.g. numeric and decimal validations. I want to validate the textbox in which email address is entered.... can any1 suggest me any link to the email address validation code? Since it is a windows application,i cant use javascript for it. Thanks Riz
Hi, If have this solution in VB.NET. So it wil be helpfull for you. Regards Public Shared Function ValidEmailAddress(ByVal emailAddress As String, ByRef errorMessage As String, ByVal Textbox As System.Windows.Forms.TextBox) As Boolean ' Confirm there is text in the control. If Textbox.Text.Length = 0 Then Return True else errorMessage = "E-mail address is required." Return False End If ' Confirm that there is an "@" and a "." in the e-mail address, and in the correct order. If emailAddress.IndexOf("@") > -1 Then If (emailAddress.IndexOf(".", emailAddress.IndexOf("@")) > emailAddress.IndexOf("@")) Then errorMessage = "" Return True End If End If errorMessage = "E-mail address must be valid e-mail address format." + ControlChars.Cr + _ "For example 'someone@example.com' " Return False End Function Hi, If have this solution in VB.NET. So it wil be helpfull for you. Regards H.w. Hendrick, Netherlands