|
-
Apr 5th, 2010, 01:03 PM
#1
Thread Starter
Addicted Member
Validating E-mail Address In Textbox?
I would like to know if there is a simple way to validate an e-mail address? I have seen many ways that appear to use functions but I would like to use something simple because currently my error control is done like this:
If txtEmail.Text = "" Then
ErrorProvider1.SetError(txtEmail, "You must enter your e-mail address.")
Else
ErrorProvider1.SetError(txtEmail, "")
Is there a way to use the same type of syntax but instead of checking if the textbox is empty, check if it a valid e-mail address? I know the regular expressions can be used, but how in this circumstance?
-
Apr 5th, 2010, 01:20 PM
#2
Hyperactive Member
Re: Validating E-mail Address In Textbox?
What characters do you consider invalid?
Remember to click on the scales to the left and rep me if I helped 
-
Apr 5th, 2010, 01:31 PM
#3
Thread Starter
Addicted Member
Re: Validating E-mail Address In Textbox?
I would like to ensure it is a valid e-mail address, such as the regular express checks for.
-
Apr 5th, 2010, 01:43 PM
#4
Re: Validating E-mail Address In Textbox?
Code:
Dim EmailRegEx As New System.Text.RegularExpressions.Regex("\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*")
If EmailRegEx.IsMatch(YourTextBoxHere.Text.Trim) Then
'Is valid
Else
'Not valid
End If
-
Apr 5th, 2010, 01:49 PM
#5
Thread Starter
Addicted Member
Re: Validating E-mail Address In Textbox?
Thank you! I was having trouble with the expressions for some reason. Every time I tried one, it wasn't the right one because it wasn't ever letting a valid e-mail address pass through. Thank you so much!!!
-
Apr 5th, 2010, 01:52 PM
#6
Re: Validating E-mail Address In Textbox?
No problem, be sure to mark your thread as Resolved.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|