hey
thanx to u all
i've been to the site
where i found this asp code for email validation
<html>
<head>
<title>VBscript email validation</title>
</head>
<body>
<%
Dim emailAddress
emailAddress = Request("emailAddress"
if emailAddress <> "" then
emailAddress = Cstr(emailAddress)
if emailAddress <> "" then
blnValidEmail = RegExpTest(emailAddress)
if blnValidEmail then
Response.Write("Valid email address"
else
Response.Write("Not a valid email address"
end if
end if
Function RegExpTest(sEmail)
RegExpTest = false
Dim regEx, retVal
Set regEx = New RegExp
' Create regular expression:
regEx.Pattern ="^[\w]{1,}\@([\da-zA-Z-]{1,}\.){1,}[\da-zA-Z-]{2,3}$"
' 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
Else
%>
<form>
<input type="text" name="emailAddress">
<input type="submit" value="submit">
</form>
<%End If %>
</body>
</html>
well this code runs well in .asp file
i modified this code so that it can be used in .html file
the code i modified is as follows
<html>
<head>
<title>VBscript email validation</title>
</head>
<body>
<script language="vbscript">
<!--
Sub btn_reg_onclick
Dim emailAdd
emailAdd = form1.emailAddress
if emailAdd <> "" then
emailAdd = Cstr(emailAdd)
if emailAdd <> "" then
blnValidEmail = RegExpTest(emailAdd)
if blnValidEmail then
alert "Valid email address"
else
alert "Not a valid email address"
end if
end if
RegExpTest(sEmail)
Else
msgbox "hi"
End If
End Sub
Function RegExpTest(sEmail)
RegExpTest = false
Dim regEx, retVal
Set regEx = New RegExp
' Create regular expression:
regEx.Pattern ="^[\w]{1,}\@([\da-zA-Z-]{1,}\.){1,}[\da-zA-Z-]{2,3}$"
' 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="form1">
Enter e-Mail Address<input type="text" name="emailAddress"><br>
<input name="btn_reg" type="submit" value="Click To Register">
</form>
</body>
</html>
when i run the above .html file & if i enter invalid email
address it shows proper alert message but if i enter a valid email address then also it shows the same message i.e "not a valid email address" why is that happening??
also it is not giving the "hi" message
can u help me out with this code please
i know that there is a mistake in the code but i cant figure out what
thanx to u all
i've been to the site
where i found this asp code for email validation
<html>
<head>
<title>VBscript email validation</title>
</head>
<body>
<%
Dim emailAddress
emailAddress = Request("emailAddress"
if emailAddress <> "" then
emailAddress = Cstr(emailAddress)
if emailAddress <> "" then
blnValidEmail = RegExpTest(emailAddress)
if blnValidEmail then
Response.Write("Valid email address"
else
Response.Write("Not a valid email address"
end if
end if
Function RegExpTest(sEmail)
RegExpTest = false
Dim regEx, retVal
Set regEx = New RegExp
' Create regular expression:
regEx.Pattern ="^[\w]{1,}\@([\da-zA-Z-]{1,}\.){1,}[\da-zA-Z-]{2,3}$"
' 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
Else
%>
<form>
<input type="text" name="emailAddress">
<input type="submit" value="submit">
</form>
<%End If %>
</body>
</html>
well this code runs well in .asp file
i modified this code so that it can be used in .html file
the code i modified is as follows
<html>
<head>
<title>VBscript email validation</title>
</head>
<body>
<script language="vbscript">
<!--
Sub btn_reg_onclick
Dim emailAdd
emailAdd = form1.emailAddress
if emailAdd <> "" then
emailAdd = Cstr(emailAdd)
if emailAdd <> "" then
blnValidEmail = RegExpTest(emailAdd)
if blnValidEmail then
alert "Valid email address"
else
alert "Not a valid email address"
end if
end if
RegExpTest(sEmail)
Else
msgbox "hi"
End If
End Sub
Function RegExpTest(sEmail)
RegExpTest = false
Dim regEx, retVal
Set regEx = New RegExp
' Create regular expression:
regEx.Pattern ="^[\w]{1,}\@([\da-zA-Z-]{1,}\.){1,}[\da-zA-Z-]{2,3}$"
' 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="form1">
Enter e-Mail Address<input type="text" name="emailAddress"><br>
<input name="btn_reg" type="submit" value="Click To Register">
</form>
</body>
</html>
when i run the above .html file & if i enter invalid email
address it shows proper alert message but if i enter a valid email address then also it shows the same message i.e "not a valid email address" why is that happening??
also it is not giving the "hi" message
can u help me out with this code please
i know that there is a mistake in the code but i cant figure out what