Spammers have robots that search the Web for such forms and when they find one, they use automated programs to submit thousands of spam. Webmasters have developed a method to prevent such abuse. In this article, I show you three different examples of using Java Script to implement this method for your own web form.
Welcome to Bucaro TecHelp!

Bucaro TecHelp
Maintain Your Computer and Use it More Effectively
to Design a Web Site and Make Money on the Web

About Bucaro TecHelp About BTH User Agreement User Agreement Privacy Policy Privacy Site Map Site Map Contact Bucaro TecHelp Contact RSS News Feeds News Feeds

Victims of Sandy Hook

Stop the Slaughter of Innocents. Congress is bought and paid for by gun lunatics and gun promotion groups. If you want to live in a safe America, help buy Congress back for America. Send a donation to Mayors Against Illegal Guns, 909 Third Avenue, 15th Floor New York, NY 10022

Prevent Automated Form Submissions With Java Script

you can use a submission form to allow your web site visitors communicate with you. A visitor enters their information into the form, and then they click on the [Submit] button to the send the information to your email or to an application on your server. Unfortunately, spammers have robots that search the Web for such forms and when they find one, they use automated programs to submit thousands of spam.

Webmasters have developed a method to prevent such abuse. You've probably encountered this method yourself when you tried to submit a form. The form displays a password that you must type in before you can submit the form. The spammer's robot cannot read the password because it's not character code, it's an image. Sometimes the image uses a different font for each character and also has extraneous lines and marks. This prevents optical character readers from reading the password.

In this article, I'm going to present you with three different examples of using Java Script to implement this method for your own web form. Each subsequent method will use greater sophistication to create a graphic image password. You might think the code for such a feature would be extremely complicated, but it actually turns out to be amazingly simple.

The first thing that I want to present to you is some basic Java Script code for extracting data from a form and validating it before submitting the from to the server. This code is shown below.

function MyDomain(field)
{
  if(field.indexOf("bucarotechelp.com") < 0)
  {
    return(false);
  }
  else
  {
    return(true);
  }  
}

function Validate(form)
{
   var error = 0;

   if(MyDomain(form.email.value)) error = 1;

   if(error)
   {
      alert("Error");
   }
   else
   {
     form.submit();
   }
}

Examine the second function, Validate. It receives the form as an argument. The first line inside the function creates a variable named error and sets its value to 0. The second line calls the function MyDomain, passing it the data that the user typed in the form's email text box, and if MyDomain returns the value true, it sets error to 1. Below that is an if structure that, if error is 1 displays an Error message box, or if error is 0 submits the form.

Examine the first function, . It receives the data that the user typed in the form's email text box, and if it finds the domain name bucarotechelp.com in the data, it returns true to its calling function, Validate. In other words, if some fool tries to use my domain name in their email address, they get an error message and the form is NOT submitted.

RSS Feed RSS Feed

Follow Stephen Bucaro Follow @Stephen Bucaro



Web Design Sections

Fire HD
[Site User Agreement] [Privacy Policy] [Site map] [Search This Site] [Contact Form]
Copyright©2001-2016 Bucaro TecHelp 13771 N Fountain Hills Blvd Suite 114-248 Fountain Hills, AZ 85268