Print Page | Close Window

Form Validation in "Register.asp"

Printed From: LogSat Software
Category: Spam Filter ISP
Forum Name: Spam Filter ISP Support
Forum Description: General support for Spam Filter ISP
URL: http://www.logsat.com/spamfilter/forums/forum_posts.asp?TID=943
Printed Date: 23 October 2017 at 11:15am


Topic: Form Validation in "Register.asp"
Posted By: Desperado
Subject: Form Validation in "Register.asp"
Date Posted: 13 June 2003 at 10:33am

We have had quite a few users sign up using their name instead of their email address even tho our registrationpage is clearly spelled out in red that it must be their actual email address.

I added the following code just after the "Form" code and added the validation function at the very end in the "register.asp" http://file:" CLASS="ASPForums" TITLE="WARNING: URL created by poster. - http://file:

=======================================

<%
  Response.End
 End If

 'Validate the email format
 If chkEmail(Email) = 1 Then
%>
<div align="left">

<table border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td align="left"></td>
    <td align="left" width="10"></td>
    <td align="left"></td>
  </tr>
  <tr>
    <td align="left"><img src=" undefined" CLASS="ASPForums" TITLE="WARNING: URL created by poster. - http://www.mags.net/images/logo/logo_center.gif" CLASS="ASPForums" TITLE="WARNING: URL created by poster. - http://www.mags.net/images/logo/logo_center.gif "></td>
    <td align="left" width="10"></td>
    <td align="left"><font color="#FF0000"><big><big><strong>Spam Filter Registration Error</strong></big></big></font></td>
  </tr>
  <tr>
    <td align="left"></td>
    <td align="left" width="10"></td>
    <td align="left"></td>
  </tr>
</table>
</div>
<p><font face="Arial" color="#FF0000"><strong>You did not enter a valid email address!</strong></font></p>

<p><font face="Arial" color="#FF0000"><strong>Please <a href="/register.asp">Try Again</a> or
contact <a href=" undefined" CLASS="ASPForums" TITLE="WARNING: URL created by poster. - support@mags.net http://mailto:support@mags.net" CLASS="ASPForums" TITLE="WARNING: URL created by poster. - http://mailto:support@mags.net ">support@mags.net</a> for help.</strong></font></p>
</body>
</html>

<%

===================

<%
' Added Email format chacking 6-13-2002  DAS

function chkEmail(theAddress)
   ' checks for a vaild email
   ' returns 1 for invalid addresses
   ' returns 0 for valid addresses
   dim atCnt
   chkEmail = 0

   ' chk length
   if len(theAddress) < 5  then
      ' mailto:a@b.c" CLASS="ASPForums" TITLE="WARNING: URL created by poster. - a@b.c should be the shortest an
      ' address could be
      chkEmail = 1
 
   ' chk format
   ' has at least one "@"
   elseif instr(theAddress,"@") = 0 then
      chkEmail = 1
 
   ' has at least one "."
   elseif instr(theAddress,".") = 0 then
      chkEmail = 1
 
   ' has no more than 3 chars after last "."
   elseif len(theAddress) - instrrev(theAddress,".") > 3 then
      chkEmail = 1
 
   ' has no "_" after the "@"
   elseif instr(theAddress,"_") <> 0 and _
       instrrev(theAddress,"_") > instrrev(theAddress,"@")  then
      chkEmail = 1

   else
      ' has only one "@"
      atCnt = 0
      for i = 1 to len(theAddress)
         if  mid(theAddress,i,1) = "@" then
            atCnt = atCnt + 1
         end if
      next
 
      if atCnt > 1 then
         chkEmail = 1
      end if

      ' chk each char for validity
      for i = 1 to len(theAddress)
        if  not isnumeric(mid(theAddress,i,1)) and _
  (lcase(mid(theAddress,i,1)) < "a" or _
  lcase(mid(theAddress,i,1)) > "z") and _
  mid(theAddress,i,1) <> "_" and _
  mid(theAddress,i,1) <> "." and _
  mid(theAddress,i,1) <> "@" and _
  mid(theAddress,i,1) <> "-" then
            chkEmail = 1
        end if
      next
  end if
end function
%>

I hope this will slow down some of the "I never got my registration password" phone calls.

Dan

 




Print Page | Close Window