Modern ASP Email Validation Function?

Results 1 to 2 of 2

Thread: Modern ASP Email Validation Function?

  1. #1
    Join Date
    Dec 1969

    Default Modern ASP Email Validation Function?

    Hi guys, <BR><BR>We&#039;ve been using the following email validation function for a while:<BR><BR><BR>&#060;%<BR>Function VerifyEmail(strEmail)<BR> u_email= ucase(trim(strEmail)) <BR> email_len=len(u_email)<BR> if trim(u_email) &#060;&#062; "" then <BR> for counter = 1 to email_len <BR> if mid(u_email,counter,1)="@" then <BR> at_counter=at_counter+1<BR> if at_counter &#062; 1 then <BR> message = message &"There appear to be multiple @&#039;s in the email address<BR>" <BR> end if<BR> <BR> if u_at = "" then<BR> u_at=counter<BR> end if <BR> end if <BR> <BR> if mid(u_email,counter,1)="." then <BR> if u_dot = "" then<BR> u_dot=counter<BR> u_dot_counter = u_dot_counter + 1<BR> end if &#039;end check for the first dot <BR> end if &#039;end check for the dot <BR> next <BR> <BR> &#039; Check to see if the dot comes after the @<BR> &#039; and that the first dot is not the last character<BR> if ((len(u_email) &#060;= u_dot+1) or (at_counter &#060; 1) or (u_dot_counter &#060; 1)) then &#039;&#039;(u_dot &#060; u_at) or or ((u_dot-u_at) &#060; 2)<BR> message = message & "Email convention appears to be wrong <BR>"<BR> end if &#039;end check for dot after the @<BR> <BR> for counter=1 to len(u_email) <BR> if (mid(u_email,counter,1) &#060;&#062; "/") and ((mid(u_email,counter,1) &#062; chr(45)) and (mid(u_email,counter,1) &#060; chr(58))) or ((mid(u_email,counter,1) &#062; chr(63)) and (mid(u_email,counter,1) &#060; chr(91))) then<BR> <BR> else<BR> &#039; If it&#039;s an invalid charcter add it to the display message<BR> message = message & "Invalid charcter "& mid(u_email,counter,1)& " found in email address <BR>"<BR> end if &#039;end check for invalid characters <BR> next &#039;end loop for invalid characters<BR> end if &#039;end check for user input<BR> <BR> &#039; If the email address os not OK than display the message(s)<BR> &#039; and show the text box for user input with the last value pre-filled<BR> if message &#060;&#062; "" or u_email = "" then<BR> VerifyEmail = false<BR> else <BR> VerifyEmail = true<BR> end if <BR> <BR>End Function<BR>%&#062;<BR><BR>We increasingly having more problems with this function as email addresses are allowed more characters that didn&#039;t exist in the old days. I&#039;m wondering if anyone has a modern email validation function, that recognises and accepts all modern accepted email characters, and addresses. If you have a nicer version please post here.<BR><BR>Thanks<BR><BR>James

  2. #2
    Join Date
    Dec 1969

    Default Here's something I found...

    ...through Google:<BR><BR>Oliver.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts