La siguiente función sirve para validar que una dirección de correo electrónico (email) sea correcta en ASP.
<%
function revCorreo(Correo)
' revisa dirección valida
' regresa 1 para direcciones invalidas
' regresa 0 para direcciones validas
dim atCnt
revCorreo = 0
' chk length
if len(Correo) < 5 then
' z@q.c debería ser la dirección mas corta posible
revCorreo = 1
' revisa formato
' revisa que tenga una @
elseif instr(Correo,"@") = 0 then
revCorreo = 1
' revisa que tenga un .
elseif instr(Correo,".") = 0 then
revCorreo = 1
' revisa que no tenga mas de tres caracteres despues del .
elseif len(Correo) – instrrev(Correo,".") > 4 then
revCorreo = 1
' que no tenga _ después de @
' elseif instr(Correo,"_") <> 0 and _
' instrrev(Correo,"_") > instrrev(Correo,"@") then
' revCorreo = 1
else
' que tenga solo una @
atCnt = 0
for i = 1 to len(Correo)
if mid(Correo,i,1) = "@" then
atCnt = atCnt + 1
end if
next
if atCnt > 1 then
revCorreo = 1
end if
' revisa caracter por caracter
for i = 1 to len(Correo)
if not isnumeric(mid(Correo,i,1)) and _
(lcase(mid(Correo,i,1)) < "a" or _
lcase(mid(Correo,i,1)) > "z") and _
mid(Correo,i,1) <> "_" and _
mid(Correo,i,1) <> "." and _
mid(Correo,i,1) <> "@" and _
mid(Correo,i,1) <> "-" then
revCorreo = 1
end if
next
end if
end function
%>