Click to See Complete Forum and Search --> : Swear word filter ??


Asch
12-31-2002, 03:55 AM
Hi, i ve made an swear word filter by using java for an form that subscribes to a guestbook...The problem is that by sending the form, it reconises the swear word but does not stop transmission to to the ".cgi"...So i ve find the error but i can resolve it. It's the sending button i've put an image for it ...
<input TYPE=image SRC="...add.gif"onclick="validate_comments();" BORDER=no>

but if I put this with an normal buton it works !!;O)
<input TYPE="button" style"....." onclick="validate_comments();" BORDER=no>

I want it with the image, don t know why it doesn t work, cause for me it s almost the same....

hop you can help me thanks

asch....
:confused:

Charles
12-31-2002, 05:09 AM
You need to call your validator from the onsucmit handler of the form:

<form action="book.pl" onsubmit="return validate_comments()">

And you need to make sure that validate_comments() returns false when you want the submission canceled.

This has nothing to do with the correctness of your script, but it's traditional in Java and in JavaScript (two very different and unrelated scripting languages) to write a name like validate_comments as validateComments.

Asch
12-31-2002, 07:23 AM
Yeah !! great thats it... thanks..:O)....you seem to be pretty good in programming lol so i have another question..??..;)

I ve made a list of words like this

var swear_words_arr=new Array("word1","word2", etc....);

now the problem is that people can right the word with spaces in between you now what i mean lol ...my english is not perfect so..!!
for exemple:the famous "****" :O)...they can right it like that "f uc * k", iv done something like that :
"f`?.?u`?.?c`?.?k" but it doesnt seem to work ??
do you have an idea ????

thanks and happy new year !!!:D

Charles
12-31-2002, 07:37 AM
You need to use what are called "Regular Expressions". See http://developer.netscape.com/docs/manuals/js/client/jsref/index.html for details, and you might find http://sitescooper.org/tao_regexps.html helpful. As a last resort, post the URL of the page and some of us will see what we can do.