SteveH
01-29-2008, 11:59 AM
Hello
I have an online form (in Flash) which I would like to send (via ASP) error messages to. This can be done in Flash's Action Script, but I prefer server messages instead.
When the site visitor completes the online form, he should get error messages back if that form is completed incorrectly.
What is the best way of doing this? Would it be something like this:
<%
Dim ErrorMsg,name,email,business,country,message
dim re, results, i
Dim errorArray(100)
For i = 0 TO 100
errorArray(i) = "black"
Next
fullname = Request.Form("name")
email = Request.Form("email")
business = Request.Form("business")
country = Request.Form("country")
message = Request.Form("message")
ErrorMsg = ""
set re = New RegExp
'Name
re.Pattern = "^[^0-9\/><\.,\\!\^\$\*\+\?@#%&\(\);:\[\]\{\}=""']+$"
re.Global = True
re.IgnoreCase = True
if Not re.Test(fullname) then
errorArray(0) = "red"
ErrorMsg = ErrorMsg & "<center>Please type in your full name</center>"
end if
'Email
re.Pattern = "^\w+@\w+\.\w+"
If Not re.Test(email) Then
errorArray(1) = "red"
ErrorMsg = ErrorMsg & "<center>Please type in a valid email address</center>"
end if
'Business
if Len(business) = 0 then
errorArray(2) = "red"
ErrorMsg = ErrorMsg & "<center>Please type in your area of business</center>"
end if
'Country
if Len(country) = 0 then
errorArray(3) = "red"
ErrorMsg = ErrorMsg & "<center>Please type in the name of your country</center>"
end if
'Message
if Len(message) = 0 then
errorArray(4) = "red"
ErrorMsg = ErrorMsg & "<center>Please type in your message</center>"
End if
' if no errors
If ErrorMsg = "" Then
' go on to next page
End if
%>
<font color="red" face="verdana" size="1"><b><%= ErrorMsg %></b></font>
Many thanks for any advice.
Steve
I have an online form (in Flash) which I would like to send (via ASP) error messages to. This can be done in Flash's Action Script, but I prefer server messages instead.
When the site visitor completes the online form, he should get error messages back if that form is completed incorrectly.
What is the best way of doing this? Would it be something like this:
<%
Dim ErrorMsg,name,email,business,country,message
dim re, results, i
Dim errorArray(100)
For i = 0 TO 100
errorArray(i) = "black"
Next
fullname = Request.Form("name")
email = Request.Form("email")
business = Request.Form("business")
country = Request.Form("country")
message = Request.Form("message")
ErrorMsg = ""
set re = New RegExp
'Name
re.Pattern = "^[^0-9\/><\.,\\!\^\$\*\+\?@#%&\(\);:\[\]\{\}=""']+$"
re.Global = True
re.IgnoreCase = True
if Not re.Test(fullname) then
errorArray(0) = "red"
ErrorMsg = ErrorMsg & "<center>Please type in your full name</center>"
end if
re.Pattern = "^\w+@\w+\.\w+"
If Not re.Test(email) Then
errorArray(1) = "red"
ErrorMsg = ErrorMsg & "<center>Please type in a valid email address</center>"
end if
'Business
if Len(business) = 0 then
errorArray(2) = "red"
ErrorMsg = ErrorMsg & "<center>Please type in your area of business</center>"
end if
'Country
if Len(country) = 0 then
errorArray(3) = "red"
ErrorMsg = ErrorMsg & "<center>Please type in the name of your country</center>"
end if
'Message
if Len(message) = 0 then
errorArray(4) = "red"
ErrorMsg = ErrorMsg & "<center>Please type in your message</center>"
End if
' if no errors
If ErrorMsg = "" Then
' go on to next page
End if
%>
<font color="red" face="verdana" size="1"><b><%= ErrorMsg %></b></font>
Many thanks for any advice.
Steve