string replace

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
nincha
Forum Contributor
Posts: 191
Joined: Fri Mar 28, 2003 12:30 pm
Location: CA, USA

string replace

Post by nincha »

any one got an idea how i can use javascript onSubmit to replace all bad words in the textarea field?
User avatar
delorian
Forum Contributor
Posts: 223
Joined: Sun May 04, 2003 5:20 pm
Location: Olsztyn, Poland

Post by delorian »

Why do you want to do this using Javascript. Someone can send the text with bad words omitting you anti-bad-word-system. It's better to do it with PHP e.g.:

Code: Select all

$good_txt = preg_replace("(bad_word1|bad_word2|bad_word3)i","[censored]",$_POST['textarea_bad_txt']);
Or you can have those bad words in the table and make a loop.
Post Reply