Forms JavaScript Code Snippets

These snippets (and a few tutorials) all deal with Javascript forms. We’ll show you some really neat forms that keep you from receiving bogus information as well as others that are just fun to play with (test personal info).

Results via Envato Market

This script counts down how many years, months, days, hours, minutes and seconds to go until a special time you designate.

Validate dates in your form using this universal script. Will work with any date format and the code is fully commented for easy modification. Great!

Let Javascript help you receive feedback from your visitors. The script also requires that all fields must be completed before the form is submitted. Great!

Ensure that your visitors enter a properly formatted 5 digit, or 5 digit+4 zip code. The visitor is alerted if any information is invalid and asked to try again. Cool!

This function verifies that a string is a valid time, in the form hh:mm:ss am/pm, where seconds are optional. It accepts military time (hour between 0 and 23) as long as am/pm isn’t specified. It requires am/pm when the hour is less than or equal to 12.

Validates date in form (date must be on or before current date). Checks days in February and formats dates as xx/xx/xxxx

This script works like our Password Verifier, however, it also checks for a minimum length and invalid characters.

Use JavaScript to ensure that visitors choose both a radio button and a checkbox. Invalid submissions are cancelled.

Input the Social Security Number using either the 9 digit or NNN-NN-NNNN format. The number ranges can be easily changed by the S.S.A, so this is not checked.