Title: Javascript for Spam Bot Control
Last modified: August 18, 2016

---

# Javascript for Spam Bot Control

 *  [mtanner](https://wordpress.org/support/users/mtanner/)
 * (@mtanner)
 * [21 years, 5 months ago](https://wordpress.org/support/topic/javascript-for-spam-bot-control/)
 * I ran a couple of searches before posting this (maybe using the wrong keywords)
   but anyhoo I ran across a simple little javascript on the web that will only 
   submit a form (i.e. wp comments) when the user enters a value that you create.
   It’s not as sophisticated as a random image generated one but it seems to be 
   doing the trick. [Check it out here](http://lab.artlung.com/scripting/validate_image/)
   If I’m late on this sorry just trying to help out.

Viewing 3 replies - 1 through 3 (of 3 total)

 *  Thread Starter [mtanner](https://wordpress.org/support/users/mtanner/)
 * (@mtanner)
 * [21 years, 5 months ago](https://wordpress.org/support/topic/javascript-for-spam-bot-control/#post-119431)
 * Oh PS if you implement this into your wordpress site SOMEONE please post instructions
   for other members.
 *  Moderator [James Huff](https://wordpress.org/support/users/macmanx/)
 * (@macmanx)
 * [21 years, 5 months ago](https://wordpress.org/support/topic/javascript-for-spam-bot-control/#post-119451)
 * See this one: [http://www.gudlyf.com/index.php?p=376](http://www.gudlyf.com/index.php?p=376)
   “
   This version now includes the ability to generate phonetic-English text if you
   donâ€™t want to (or canâ€™t) create an image.”
 *  [bwehrle](https://wordpress.org/support/users/bwehrle/)
 * (@bwehrle)
 * [21 years, 5 months ago](https://wordpress.org/support/topic/javascript-for-spam-bot-control/#post-119487)
 * I would like to propose a slightly different fix that is purely client side and
   much simpler.
    Here is my fix for this particular problem. I change the link 
   using javascript. When the index.php page loads in a _real_ browser, the link
   on the post page will change. The name of the real link should be unique. Here
   I use an example which ideally everyone should change. Unless the spammer actually
   parse for this hac, they will go to my “enable javascript please” page. Since
   making this change I have had no spam, and I believe that this is a highly effective
   manner of using Javascript. You must change the file wp-comments-post.php to 
   a different name. Here I use wp-comments-nospamplease-post.php. Then create a
   new file for the bogus post page. I created a file called wp-enable-javascript.
   php and it instructs people to enable JS on their browsers. Below are the file
   names and the changes I made to them, not including the change I just mentioned
   above. wp-comments.php: Change the post attribute to point to your bogus page.
   Before: —————- `<form action="<?php echo get_settings('siteurl'); ?>/wp-comments-
   nospamplease-post.php" method="post" id="commentform">` After: —————- `<form 
   action="<?php echo get_settings('siteurl'); ?>/wp-enable-javascript.php" method
   ="post" id="commentform">` index.php: Add the following Javascript code to the
   header ————————————————- `<head profile="http://gmpg.org/xfn/1"> <title><?php
   bloginfo('name'); ?><?php wp_title(); ?></title> <SCRIPT language="JavaScript"
   > <!-- function changePostLink() { var action = action="<?php echo get_settings('
   siteurl'); ?>/wp-comments-nospamplease-post.php"; var node = document.getElementById("
   commentform"); if ( node == null) { return; } node.setAttribute("action", action);}//--
   >  </SCRIPT> And change the body tag to include the onLoad attribute: ——————————————————–
   Before: ——– <body> After: —— <body onload="changePostLink(); return true;">

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Javascript for Spam Bot Control’ is closed to new replies.

 * 3 replies
 * 3 participants
 * Last reply from: [bwehrle](https://wordpress.org/support/users/bwehrle/)
 * Last activity: [21 years, 5 months ago](https://wordpress.org/support/topic/javascript-for-spam-bot-control/#post-119487)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
