Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Email Validation Using VBScript

Status
Not open for further replies.

mad411

Technical User
Apr 4, 2002
17
IN
hi,

here's email validation code using vbscript



<HTML>
<HEAD>
<TITLE>E-Mail Validation using VBScript</TITLE>
</HEAD>
<BODY>
<script language=&quot;vbscript&quot;>
<!--

function emailval()
Dim emailAdd
emailAdd = form1.emailAddress
if emailAdd <> &quot;&quot; then
emailAdd = Cstr(emailAdd)
if emailAdd <> &quot;&quot; then
blnValidEmail = RegExpTest(form1.emailAddress.value)
if blnValidEmail then
alert &quot;Valid email address&quot;
else
alert &quot;Not a valid email address&quot;
end if
end if
RegExpTest(sEmail)
Else
msgbox &quot;hi&quot;
End If

end function
Function RegExpTest(sEmail)
RegExpTest = false
Dim regEx, retVal
Set regEx = New RegExp

' Create regular expression:
regEx.Pattern =&quot;^[\w]{1,}\@([\da-zA-Z-]{1,}\.){1,}[\da-zA-Z-]{2,3}$&quot;

' Set pattern:
regEx.IgnoreCase = true

' Set case sensitivity.
retVal = regEx.Test(sEmail)

' Execute the search test.
If not retVal Then
exit function
End If

RegExpTest = true
End Function

-->
</script>
<form name=&quot;form1&quot; method=&quot;post&quot; action=&quot;valid.html&quot;>
<input maxLength=&quot;60&quot; size=&quot;30&quot; name=&quot;emailAddress&quot; >
<input name=btn_reg onclick =&quot;emailval()&quot; type=&quot;submit&quot; value=&quot;Click To Register&quot;></P>
</form>
</BODY>
</HTML>


[noevil]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top