Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

asp form validation can someone look at this and tell me what is wrong

Status
Not open for further replies.

n0795

Programmer
Jul 30, 2001
136
US
<%
Form_Name = Trim(Request.Form(&quot;discription&quot;))

Validated_Form = true

IF InStr(Form_discription,&quot;badword1,badword2&quot;)=1 THEN
Validated_Form = false
END IF

IF NOT Validated_Form THEN
%>
<HTML>
<BODY>
Click back in your browser, and fill it out properly!
</HTML>
</BODY>
<%
ELSE
I have code in here that submits to a database and asp email but this works ok....%>
<%
end if
%>
 
First that I can see is that your instr function is not syntaxed properly. It has three parts and you only show two.

Proper syntax should be: InStr(Form_discription,&quot;badword1&quot;,&quot;badword2&quot;)

Hope this helps,

Tazzmann
 
I have got this to work with only one word in the
InStr(Form_discription,&quot;badword1&quot;)=1 THEN
But not two
InStr(Form_discription,&quot;badword1&quot;,&quot;badword2&quot;)=1 THEN
Im close I think


 
found another problem this code only checks if that is the only word in the textarea
IE if i write &quot;hello badword1&quot; it lets it go but if i just enter &quot;badword1&quot; in the textarea it works
Any ideas
 
Make sure you are looking for the proper output...

The InStr function returns the following values:
If InStr returns
string1 is zero-length 0
string1 is Null Null
string2 is zero-length start
string2 is Null Null
string2 is not found 0
string2 is found within string1 Position at which match is found
start > Len(string2) 0



Tazzmann
 
Basicly I have Textarea named &quot;discription&quot; and I would like to check this field and all the words in it for any bad words listed in my string 'below'
<%
Form_discription = Request.Form(&quot;discription&quot;)

Validated_Form = true

IF InStr(Form_discription,&quot;badword&quot;)=1 THEN ....&quot;here i would like to put more words&quot;.......
Validated_Form = false
END IF

IF NOT Validated_Form THEN
%>
<HTML>
<BODY>
We said cussing . Click back in your browser, and fill it out properly!
</BODY>
</HTML>

<%
ELSE
'Here you can insert the info to a database, or send it
'with JMail to you mail account. If you send it to a db, make sure
'to remove any possible ' chars.%>
What do I need to change to do this.?
What am I doing wrong Im kinda new to ASP
Any help would be great....
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top