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!

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

[About BTH]  [User Agreement]  [Privacy Policy]  [Site Map]  [Contact Form]  [Advertise on BTH]  [News Feed]

Google
Web
This Site

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.

Web Design Sections

RSS Feed RSS Feed

Easy Java Script Code
Easy Slide Show Code
Easy Slide Show Code with Mouseover Pause
Easy Slide Show Code With Linked Slides
Slide Show with Different Size Images
Easy Java Script Timer Code
Easy Java Script Windows
Easy Rollovers
Easy Picture Transition Effects
Easy Moving Popup Code
Easy Picture Zoom Code
Easy Picture Panning Code
Easy Java Script Animation
Easy JavaScript Picture Selector Code
Easy Animated Banners with Java Script
Easy Java Script Form Validation
Easy Drag n Drop Code
Easy Graph Generating Code
Easy Code to Sort a Table by Column
Easy Expanding Menu Code
Web Designer's Reference
Object-Oriented JavaScript
Easy Fading Text Banner Code
Easy Expanding Banner Code
Calendars for Your Website
Date Picker For Your Web Site
Calculators For Your Web Site
Loan Payment Calculator
Length Units Converter
Body Mass Index
Fahrenheit to Celsius Converter
Decimal to Hexidecimal Converter
Easy Code for Screen Tape Adding Machine
Code for Java Script Circle⁄Sphere Calculator
Code for Java Script Cube⁄Box Volume Calculator
Round a Float to 4 Digits to the Right of the Decimal Point
Disable IE8 Accelerators on Your Website
Prevent Automated Form Submissions With Java Script
Make Your Own Graphical Digital Clock
Let Your Web site Visitors Set Font Size
How to Disable the Browser Back Button
Add More Bang to Your Content With Keyword Popup Menus
Put a Music Off Switch on Your Webpage
Java Script Random Password Generator
Password Protection Using the JavaScript Cookie Method
Password Protection Using the Frames Method
Replace Drop-down with Drag-and-drop
Submit Forms Without CGI
Code for a Less annoying Popup Window
Java Script Comparison Operators
Using the Java Script Array Object
Using the Java Script Date Object
Java Script Message Boxes
Java Script Trim Function
Convert Mixed Number to Decimal
How to Shuffle the Deck With Java Script
Web Site Menus : Which Section Am I In?
How Far Did the User Scroll?
Where Did the User Click?
Four Ways to Use Java Script Event Handlers
Create Your Own Database Using Only Notepad : CDV


[Site User Agreement]  [Advertise on This site]  [Search This Site]  [Contact Form]
Copyright©2001-2009 Bucaro TecHelp P.O.Box 18952 Fountain Hills, AZ 85269