I am writing a simple code that checks 7 emails being submitted from a form. I am trying to use a loop to go through all the emails but my code only evaluates the first email submitted. Can anyone tell me the proper way to loop through the emails?
now the functionCode:<!-- #INCLUDE FILE="validate.asp" --> <% Dim MyEmail(6) Dim Count MyEmail(0) = Request.Form("Y1") MyEmail(1) = Request.Form("A1") MyEmail(2) = Request.Form("A2") MyEmail(3) = Request.Form("A3") MyEmail(4) = Request.Form("A4") MyEmail(5) = Request.Form("A5") MyEmail(6) = Request.Form("A6") For Count = 0 to 6 If IsValidEmail(MyEmail(Count)) = False Then Response.Redirect "EmailError.asp" Else Response.Redirect "Form.asp" End If Next
Code:<% Function IsValidEmail(email) dim names, name, i, c 'Check for valid syntax in an email address. IsValidEmail = true names = Split(email, "@") if UBound(names) <> 1 then IsValidEmail = false exit function end if for each name in names if Len(name) <= 0 then IsValidEmail = false exit function end if for i = 1 to Len(name) c = Lcase(Mid(name, i, 1)) if InStr("abcdefghijklmnopqrstuvwxyz_-.", c) <= 0 and not IsNumeric(c) then IsValidEmail = false exit function end if next if Left(name, 1) = "." or Right(name, 1) = "." then IsValidEmail = false exit function end if next if InStr(names(1), ".") <= 0 then IsValidEmail = false exit function end if i = Len(names(1)) - InStrRev(names(1), ".") if i <> 2 and i <> 3 then IsValidEmail = false exit function end if if InStr(email, "..") > 0 then IsValidEmail = false end if end function %>




Reply With Quote