Email Address Validation:
Syntax: <%=validateEmail("
[email protected]
")%>
Code:
Highlight
<% function validateEmail(theAddress) ' 0 = valid ' 1 = invalid dim atCount validateEmail = 0 if len(cstr(theAddress)) < 5 then validateEmail = 1 elseif instr(theAddress,"@") = 0 then validateEmail = 1 elseif instr(theAddress,".") = 0 then validateEmail = 1 elseif len(theAddress) - instrrev(theAddress,".") > 3 then validateEmail = 1 elseif instr(theAddress,"_") <> 0 and _ instrrev(theAddress,"_") > instrrev(theAddress,"@") then validateEmail = 1 else atCount = 0 for i = 1 to len(theAddress) if mid(theAddress,i,1) = "@" then atCount = atCount + 1 end if next if atCount > 1 then validateEmail = 1 end if 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 validateEmail = 1 end if next end if end function %>