Link to home
Start Free TrialLog in
Avatar of Ernesto
ErnestoFlag for Mexico

asked on

How to validate a email format in asp

how to validate if the email format its ok, then do not submit

set conn=Server.CreateObject("ADODB.Connection")
'conn.Provider="Provider=SQLOLEDB"


sql="INSERT INTO comentarios (nombre, email,telefono, producto, comentario)"
sql=sql & " VALUES "
sql=sql & "('" & Request.Form("fname") & "',"
sql=sql & "'" & Request.Form("email") & "',"
sql=sql & "'" & Request.Form("telefono") & "',"
sql=sql & "'" & Request.Form("consultorio") & "',"
sql=sql & "'" & Request.Form("message") & "')"

on error resume next
conn.Execute sql,recaffected
if err<>0 then
  Response.Write("Error, Intente otro metodo de contacto!")
 Response.Write("<a href='http://www.tasasystemasasmx.com/contacaato.html'><h3>Regresar a página de contacto.</h3></a>")
else
 Response.Write("<h3>Nos pondremos en contacto lo antes posible.</h3>")
 Response.Write("<a href='http://www.totalsyssdstems.com/indicase.html'><h3>Regresar a Oncología del Bajío.</h3></a>")
  

end if
conn.close

Open in new window

Avatar of Scott Fell
Scott Fell
Flag of United States of America image

How do you want to validate? Do you want to just look for an @ symbol?  

 if  InStr(submitted_email,"@") > 0 then response.write "valid email"

Open in new window


https://www.w3schools.com/asp/func_instr.asp
Avatar of Ernesto

ASKER

I need do not submit the form and put a error message.
"for send a form please input a valid mail"  or something like that
regards
SOLUTION
Avatar of Scott Fell
Scott Fell
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Big Monty, will your regex work for the new tld's with more than 3 characters after the @ sign?
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
>  4 chars for the TLD.

yea, I would just nix that. I have one client with 6.  This list shows the newest possibilities. http://data.iana.org/TLD/tlds-alpha-by-domain.txt

I think just having the @ sign with at least 2 characters after the period will not get you in trouble.

That gets you a quick validation of possibilities. But a true verification will be an actual email to the address verification.
Avatar of Ernesto

ASKER

oh men,
tsm
I find this fancy way  but

<form  method="post" action="https://script.google.com/macros/s/AKfycbwMxYDrufp73bKdU8gMvxFDdHRuzcR4IKQUB33B7GqwyfyZS04/exec"> 

Open in new window


 <input type="text" name="email" id="email" required placeholder="Dirección de Email">
                    <span id="email-invalid" style="display:none">
                        Must be a valid email address
                    </span>

Open in new window


but i need to figured out when the email its okey acorrding to the "action="https://script.google.com/macros/s/AKfycbwMxYDrufp73bKdU8gMvxFDdHRuzcR4IKQUB33B7GqwyfyZS04/exec"

how to submit to my  "action=contact.asp"

in order to save the fields in the database,
i dont understand what you're saying...did you try either one of our suggestions?
Avatar of Ernesto

ASKER

This is the source

https://github.com/dwyl/html-form-send-email-via-google-script-without-server/blob/master/index.html#L11

I need to figured out when its ok  then pass to my contact.asp

regards you experts,!
Avatar of Ernesto

ASKER

i need 2 actions in the post
when its all ok acording

action="https://script.google.com/macros/s/AKfycbwMxYDrufp73bKdU8gMvxFDdHRuzcR4IKQUB33B7GqwyfyZS04/exec"

then do my action=contact.asp

regards
Avatar of Ernesto

ASKER

oh men,
im prety lost in here

the only that i need were   "requiered placeholder"

sorry im so new in this
im going to review your comments in order to see how to control a valid email format
regards
Avatar of Ernesto

ASKER

Tsm