Asp form filtering

  • Thread starter jfancy-Transport Canada
  • Start date
J

jfancy-Transport Canada

Hi,

I'm looking for an asp page to detect if there are any characters in my
contact form that shouldn't be there. For example, if there is a "<"
character, then this may mean there is html in my contact form, which
is not good. I want to build a string that has all the values of my
textboxes in my contact form. Its not working? Have a look:


<%

'Declare all the variables and assign them to their respective text
inputs on the feedback.asp page

dim formall : request.Form("x_name") + request.Form("x_email") +
request.Form("x_subject") + request.Form("x_comments")


'Use the In-String Function to detect on html open or close tags found
in the input boxes. If so, Don't send e-mail

if (Instr(formall,">")) OR (Instr(formall, ";")) Then

response.redirect("test2.html") 'Just a test


end if



%>




If anyone can help, it would be good!!


jf
 
A

Aaron Bertrand [SQL Server MVP]

Why don't you do this with client-side JavaScript, before the submit? You
can use regular expressions there and you will prevent (a) server activity
and (b) the user having to wait for the submission to be rejected by the
server.

What is wrong with semi-colon (;), btw?
 
R

Ray Costanzo [MVP]

Have you considered allowing those characters and just Server.HtmlEncode'ing
the strings whenever you need to display them?

Ray at work
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top