Hi guys,
I'm having difficulties with a form I want to validate.
Below I have pasted an excerpt of my code but my problem lies here:
Now this code works without any problem. The only thing is I don't want him to reload the page when a field hasn't been filled in but I want to have a messagebox popping up stating that they haven't filled in that field.
This way I prevent users from retyping everything they already typed before trying to send the form.
Now I tried a few options already where I use a piece of javascript to have an alert popup but when I test it, it still opens a new page.
So I'm completely blocked.
Please note that I'm novice to ASP so this is code that I copied from here and there so it might not be "real asp".
Below is the Send part of the code.
Thanks for your help.
I'm having difficulties with a form I want to validate.
Below I have pasted an excerpt of my code but my problem lies here:
Code:
if VNom = "" or VEmail = "" or VComment = "" then
response.redirect("react.asp")
end if
This way I prevent users from retyping everything they already typed before trying to send the form.
Now I tried a few options already where I use a piece of javascript to have an alert popup but when I test it, it still opens a new page.
So I'm completely blocked.
Please note that I'm novice to ASP so this is code that I copied from here and there so it might not be "real asp".
Below is the Send part of the code.
Thanks for your help.
Code:
if action = "Send" then
login = request.form("login")
VNom = escstring(request.form("nom"),"'")
VEmail = escstring(request.form("email"),"'")
VComment = escstring(request.form("msgText"),"'")
if VNom = "" or VEmail = "" or VComment = "" then
response.redirect("react.asp")
end if
Ye = datepart("yyyy",now())
Mm = datepart("m",now())
if Mm < 10 then
M = "0" & Mm
else
M = Mm
end if
Dd = datepart("d",now())
if Dd < 10 then
D = "0" & Dd
else
D = Dd
end if
SQLQuery= "INSERT INTO Table1 (login, nom, email, comment, jour, mois, annee) VALUES( '" &login& "','" &VNom& "','" &VEmail& "','" &VComment& "','" &D& "','" &M& "','" &Ye& "')"
OBJdbConnection.Execute SQLQuery
response.redirect("react.asp")
Comment