web blazonry web development scripts and tutorials Get best price on Unlocked Moto G Stylus
   PHP       Name Generators       Perl       CSS       Javascript       Java       MySql       How Tos       Resources   

Javascript Home

image scripts
  Image Load Order
  Mouse Overs

JavaScript Resources
  Free JavaScript Books(new)
  Recommended Sites
  Bestselling Books

Bookmark and Share

JavaScript : Form Validation

Form validation is one of the most useful applications for JavaScript. You can process the form, and try to insure that the proper information is submitted on the client side, before sending it to the server. This saves the user time if they make a small error, and it saves server resources because it does not have to process each form, and possible return the form to be completed.

The following form checks for two things, the first is that the form is not empty. Something needs to be added. The next thing it checks for is that their our no bad words used in the form. The bad words can be defined to be anything, in this example they are: "internet", "intranet", and "extranet"

Enter something:


Another thing this form does is bypass the verfication process after the first error was returned. This can be useful if you want to use the verification process as more a warning, or reminder for people to input the proper data, but not necessarily exclude them from inputing data all data. I can see this as useful for search engines, I saw a somewhere that on the Yahoo Search Engine there were something like 5,000 searches a month for the word "yahoo."

To see how this was done, use View | Page Source in your browser. Basically it just reads the value from the form, checks if it is null, parses it into individual words and then checks these words against the list of bad words.

If you need some solid, complex form validation done, Netscape has put together a script which can verify the form data, examples are valid Zip Code, Phone Numbers, Credit Cards, State Abbreviations and tons more. Their verification process uses "Regular Expressions" (a perl thing) which is in JavaScript 1.2 (Navigator 4.0). Regular Expressions can dice up strings and match patterns very easily, once you get to know how to use them.

Related Links:


Newest Pages
Test Google Ads Ver. 2
Free Linux Admin Books
Free Linux Books for Programmers
Free Books for Linux on the Desktop
Free PHP Books
Free JavaScript Books
Free Java Books - Advanced
Free Java Books - Basic
Free Perl Books
Free Python Books
Quote of the Day (PHP)
Debugging Part 2
How to Test Google Ads
Most Popular Pages
Baby Name Generator
U.S. Name Generator
Wu Name Generator
Popup Windows (JavaScript)
Upload and Resize an Image (PHP)
How To Install Apache + PHP + MySQL
Intro to Web Databases (PHP, MySQL)

Least Popular Pages
iNews Applet (Java)
Java Resources
Site Monitor (Perl)
PHP Resources

  privacy policy     ||     © 1997-2016. astonishinc.com   All Rights Reserved.