airjunkie2000 Posted June 22, 2006 Share Posted June 22, 2006 Ya know how you can use the if function to weed out strings that contain something by using "==". My problem is that I need to weed things out that contain a certain few lters in a certain order. Whats going on id people are spamming the hell out of my comment adding script and I need to block all comments and names that contain www, http, .com, or .net Any help is appreciated Thanks Quote Link to comment Share on other sites More sharing options...
abinidi Posted June 22, 2006 Share Posted June 22, 2006 Hmm... good luck with that. I'm sure there is somebody that can help. What kind of comment form do you have? Is is part of a blog or CMS? (Maybe there is a plugin that would work for you, or something.) Or is it totally home-grown? Quote Link to comment Share on other sites More sharing options...
airjunkie2000 Posted June 22, 2006 Author Share Posted June 22, 2006 home grown, really basic... I have figured out how to block an exact word, for instance if I just type "www" it will block it, but if I type "www.fjkgsdfjkgs" it will not Quote Link to comment Share on other sites More sharing options...
airjunkie2000 Posted June 28, 2006 Author Share Posted June 28, 2006 Here is a sam0ple of the if statements. I want to filter it if it "contains" the word or phrase, not if it equals it... ////////////// if(document.form1.name.value == "www") { alert("No Spamming Please"); document.form1.name.focus(); return false; } if(document.form1.comment.value == "www") { alert("No Spamming Please"); document.form1.comment.focus(); return false; } ///////////////// see this filters out "www" if you type that, but not www.spamsite.com, any suggestions? Thank you Quote Link to comment Share on other sites More sharing options...
nortk Posted June 28, 2006 Share Posted June 28, 2006 There is an .indexOf( ) method that returns the position of a string, returning -1 if the string is not found. So, something like: if (document.form1.comment.value.indexOf("www") > -1) might do the trick. Of course, you would probably want to convert to lowercase before making the comparision. Hope this helps. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.