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<br /><br />Any help is appreciated<br /><br />Thanks<!--content-->
Hmm... good luck with that. I'm sure there is somebody that can help.<br /><br />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?<!--content-->
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<!--content-->
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...<br /><br />//////////////<br /><br />if(document.form1.name.value == "www")<br />{<br />alert("No Spamming Please");<br />document.form1.name.focus();<br />return false;<br />}<br />if(document.form1.comment.value == "www")<br />{<br />alert("No Spamming Please");<br />document.form1.comment.focus();<br />return false;<br />}<br /><br />/////////////////<br /><br />see this filters out "www" if you type that, but not <!-- w --><a class="postlink" href="http://www.spamsite.com">www.spamsite.com</a><!-- w -->, any suggestions?<br /><br />Thank you<!--content-->
There is an .indexOf( ) method that returns the position of a string, returning -1 if the string is not found.<br /><br />So, something like:<br /><br />if (document.form1.comment.value.indexOf("www") > -1)<br /><br />might do the trick. Of course, you would probably want to convert to lowercase before making the comparision.<br /><br />Hope this helps.<!--content-->
Hmm... good luck with that. I'm sure there is somebody that can help.<br /><br />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?<!--content-->
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<!--content-->
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...<br /><br />//////////////<br /><br />if(document.form1.name.value == "www")<br />{<br />alert("No Spamming Please");<br />document.form1.name.focus();<br />return false;<br />}<br />if(document.form1.comment.value == "www")<br />{<br />alert("No Spamming Please");<br />document.form1.comment.focus();<br />return false;<br />}<br /><br />/////////////////<br /><br />see this filters out "www" if you type that, but not <!-- w --><a class="postlink" href="http://www.spamsite.com">www.spamsite.com</a><!-- w -->, any suggestions?<br /><br />Thank you<!--content-->
There is an .indexOf( ) method that returns the position of a string, returning -1 if the string is not found.<br /><br />So, something like:<br /><br />if (document.form1.comment.value.indexOf("www") > -1)<br /><br />might do the trick. Of course, you would probably want to convert to lowercase before making the comparision.<br /><br />Hope this helps.<!--content-->