Spam Filter ISP Support Forum

  New Posts New Posts RSS Feed - Form Validation in
  FAQ FAQ  Forum Search   Register Register  Login Login

Form Validation in "Register.asp"

 Post Reply Post Reply
Author
Desperado View Drop Down
Senior Member
Senior Member
Avatar

Joined: 27 January 2005
Location: United States
Status: Offline
Points: 1143
Post Options Post Options   Thanks (0) Thanks(0)   Quote Desperado Quote  Post ReplyReply Direct Link To This Post Topic: Form Validation in "Register.asp"
    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:

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

<%
  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="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="support@mags.nethttp://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
      ' 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

 

Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down



This page was generated in 0.230 seconds.