Good Morning/Evening All,
I am trying to place validation with a forms textbox to check that a valid email address is entered eg: ###@###.### or similar
I copied this code from a previous post and slighty modified but can't see whats wrong, I don't get an error but at the same point I don't get any response:
The code I have agaist the textbox is as follows: My Textbox is TxtEmail1
Private Sub TxtEmail1_Click()
If IsValidEmail(TxtEmail1) Then
'mail stuff here
Else
MsgBox "Not a valid email address."
End If
End Sub
Private Function IsValidEmail(value As String) As Boolean
Dim RE As Object
Set RE = CreateObject("vbscript.RegExp")
RE.Pattern = "^[a-zA-Z0-9\._-]+@([a-zA-Z0-9_-]+\.)+([a-zA-Z]{2,3})$"
IsValidEmail = RE.Test(value)
Set RE = Nothing
End Function
Any ideas what's up ? Thanks Heaps.
Cheers
Eric
I am trying to place validation with a forms textbox to check that a valid email address is entered eg: ###@###.### or similar
I copied this code from a previous post and slighty modified but can't see whats wrong, I don't get an error but at the same point I don't get any response:
The code I have agaist the textbox is as follows: My Textbox is TxtEmail1
Private Sub TxtEmail1_Click()
If IsValidEmail(TxtEmail1) Then
'mail stuff here
Else
MsgBox "Not a valid email address."
End If
End Sub
Private Function IsValidEmail(value As String) As Boolean
Dim RE As Object
Set RE = CreateObject("vbscript.RegExp")
RE.Pattern = "^[a-zA-Z0-9\._-]+@([a-zA-Z0-9_-]+\.)+([a-zA-Z]{2,3})$"
IsValidEmail = RE.Test(value)
Set RE = Nothing
End Function
Any ideas what's up ? Thanks Heaps.
Cheers
Eric