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

Handle all of your form validation using one script. This one will verify numeric strings; monitor the status of the CapsLock; verify empty strings, numeric, date, alphabetical, or e-mail fields; confirm passwords; verify the formatting of phone numbers; monitor the minimum/maximum numbers of input characters. Includes language-independent error messages and displays error messages in a div or using an alert box.

Give your users the option of changing their entries in your textareas. Add this script to your forms or use it in a WYSIWYG editor.

This script helps to insure the integrity of the date entered in drop-down menus. Dates, such as Feb 31st can’t be selected. Today’s date is automatically selected.

This script limits the length of multiple form fields and updates the screen as information is entered. It can easily be added to an existing script.

Make sure there are no stray quotes in SQL statements. Uses error counter and charAt() method to find specified character (in this case, single quote character ‘ ).

A super-easy script which eliminates any extra leading spaces entered inside a textbox. To check it out in action, try entering a few spaces before the text in the box.

A super-easy script which eliminates any extra trailing spaces entered inside a textbox. To check it out in action, try entering a few spaces after the text in the box.

This nifty little JavaScript allows the viewer to make their own web page – and they don’t need to know a scrap of HTML! Made by Michael Wieck!

The menus can be toggled on and off, instantly creating a simple tabs interface. The content is displayed accordingly to the selected tab.

Limit the time allowed for form input with this short script. Easy!