madHatter1
Technical User
Hello
I have a fairly simple form (no check boxes, etc), with 5 fields on it: name, email, business, country, message. Only a couple of these fields are essential, but once I understand how one works, I can work on the others. The problem is that, despite a fair amount of work (and countless uploadas!), I still can't get a single field to validate.
The contents of the form are passed to the databse - which works nicely - but empty wrongly-typed/fields do not generate the error messages which they should.
This is the code which I have, and would be grateful if someone could highlight the glaring error(s) I must be making.
<%option explicit%>
<%Dim ErrorMsg,fullname,email,business,country,message%>
<%
const numFields = 5
dim errorArray()
redim preserve errorArray(numFields)
if Request.Form("isSubmitted"
= "yes" then
fullname = Request.Form("fullname"
email = Request.Form("email"
business = Request.Form("business"
city = Request.Form("country"
message = Request.Form("message"
ErrorMsg = ""
dim re, results
set re = New RegExp
'Full Name
re.Pattern = "^[^0-9\/><\.,\\!\^\$\*\+\?@#%&\(\);:\[\]\{\}=""']+$"
re.Global = True
re.IgnoreCase = True
results = re.Test(fullname)
if results then
errorArray(0) = "False"
else
errorArray(0) = "True"
ErrorMsg = "First Name<br>"
end if
etc, etc, etc for each of the fields
until:
end if
%>
Beginning of HTML code here, and:
<% if ErrorMsg <> "" then %>
<font color="red" face="verdana" size"2"><b>
<%= ErrorMsg %>
</font><br>
<% end if %>
<form action="form_ac.asp" method="post">
<% if errorArray(0) = "True" then %>
<font color="red" face="verdana" size="2"><b>
<% end if %> Please type in your full name
<% if errorArray(0) = "True" then %>
</b></font>
<% end if %>
The above is repeated for each form field, each of which have the following characteristics:
<input type="text" name="fullname" value="<%= fullname %>" class="txt"></p>
I just can't see what I must be doing wrong!!
Hatter
I have a fairly simple form (no check boxes, etc), with 5 fields on it: name, email, business, country, message. Only a couple of these fields are essential, but once I understand how one works, I can work on the others. The problem is that, despite a fair amount of work (and countless uploadas!), I still can't get a single field to validate.
The contents of the form are passed to the databse - which works nicely - but empty wrongly-typed/fields do not generate the error messages which they should.
This is the code which I have, and would be grateful if someone could highlight the glaring error(s) I must be making.
<%option explicit%>
<%Dim ErrorMsg,fullname,email,business,country,message%>
<%
const numFields = 5
dim errorArray()
redim preserve errorArray(numFields)
if Request.Form("isSubmitted"
fullname = Request.Form("fullname"
email = Request.Form("email"
business = Request.Form("business"
city = Request.Form("country"
message = Request.Form("message"
ErrorMsg = ""
dim re, results
set re = New RegExp
'Full Name
re.Pattern = "^[^0-9\/><\.,\\!\^\$\*\+\?@#%&\(\);:\[\]\{\}=""']+$"
re.Global = True
re.IgnoreCase = True
results = re.Test(fullname)
if results then
errorArray(0) = "False"
else
errorArray(0) = "True"
ErrorMsg = "First Name<br>"
end if
etc, etc, etc for each of the fields
until:
end if
%>
Beginning of HTML code here, and:
<% if ErrorMsg <> "" then %>
<font color="red" face="verdana" size"2"><b>
<%= ErrorMsg %>
</font><br>
<% end if %>
<form action="form_ac.asp" method="post">
<% if errorArray(0) = "True" then %>
<font color="red" face="verdana" size="2"><b>
<% end if %> Please type in your full name
<% if errorArray(0) = "True" then %>
</b></font>
<% end if %>
The above is repeated for each form field, each of which have the following characteristics:
<input type="text" name="fullname" value="<%= fullname %>" class="txt"></p>
I just can't see what I must be doing wrong!!
Hatter