Jump to content

Recommended Posts

Posted

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

Posted

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?

Posted

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

Posted

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.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...