.
Virtual Promote Search Engine Forums Free Website Templates  
.

 

 




iWeb Toolkit: Javascript Form Field Validator

Javascript Form Field Validator

This handy javascript library provides for simple validation of the data within form fields. It uses a "validator" option within your form input fields, to match against it's library of regular expressions. To use it, follow these simple steps:
  1. Download the validation library.
    right click the link above, and choose "Save Target As" ... save it as "validator.js"
  2. Upload this to your web site, in any directory
  3. On the pages where you have a form that needs validation, add this line to your <head> </head> section, changing "/path/to" with the directory where you installed the library:

    <script language="javascript" src="/path/to/validator.js"></script>

  4. On any form that you want validated, create your form like this:

    <FORM id = "theForm" onSubmit = "return validateForm(theForm)">
    Note that you must give your form an "id", and also use that "id" in the validateForm clause

  5. For any input field that you want validated, add a "validator" clause, ie:

    <INPUT TYPE=TEXT name=ip value="128.0.0.1" validator="ipAddress">

    Valid "validator" clause values are:

Validator Clause Purpose
zipCode Matches a US zip Code (ie: 12345 or 12345-1234)
Currency Matches $17.23 or $14,281,545.45
Time Matches 5:04 or 12:34 but not 75:83
emailAddress Matches a valid email address (ie: someone@here.com or someone@here.co.uk)
phoneNumber Matches US phone (###-###-#### or (###) ###-####)
phoneNumberInternational Matches international phone numbers
ipAddress Matches a valid IP Address (###.###.###.###, all numbers being <= 255)
Date Matches a date in xx/xx/xxxx format
State Matches a US state abbreviation
SSN Matches a valid US Social Security Number


Test It Out:

A zip code:

Some currency:

A point in time:

An Email

US Phone Number

Intl Phone Number

IP Address

US State

Date (mm/dd/yyyy)

Social Security number



 

 

Sponsored Links

Search for a Free Domain
The Virtual Promote Toolkit is hosted by the experts at SimpleNet. You should be, too! Whether building a new site or transferring one, there is no other hosting platform comparable to SimpleNet’s; hosting for less than $5/month.
Search for the following tlds: .com, .net, .org, .info, .biz, & .us
Already have a domain or site? Move it to SimpleNet


spacer

 

 

     

© 1995  ·  iWeb, Inc DBA JimWorld Productions