Form Scripts - Page 2 | JavaScriptSource

Form Scripts - Page 2

These scripts (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).

In addition, be sure to check our snippets section for additional form-related scripts.

As always, we're here if you have any questions or comments. General questions about form scripts here should be posted to The JavaScript Forum.

  • Form Focus
    Lee Underwood Aug 20, 2008

    This snippet places the cursor in a selected form field upon page load. It uses the ID attribute, making it easy to target any field, regardless of form changes. Easy to add to any form.

  • Suggest Messages
    Antonio Lupetti Aug 1, 2008

    This script will display information when a field is selected with the cursor. An excellent method for providing additional or important instructions to your visitors. Easy to implement.

  • Disable Form Buttons
    Justin Barlow Jul 23, 2008

    This script will disable your submit button in order to prevent multiple form submissions. Easy to implement.

  • Multi-Value Drop Down List 2
    Kiran Pai Jul 16, 2008

    This script provides a selection in a dropdown menu, determined by the user's previous selection. Easy to implement and customize. Could be used with other dynamic languages, such as JSP or ASP. The arrays could be created by information fetched from a database.

  • so_createDateDropDown
    Steve Chipman Jul 2, 2008

    Returns a SELECT element object with dates from the current date either into the past or the future based on the value of the direction argument. Easy to add to any form.

  • Add Input Fields
    Jeroen Haan Jun 23, 2008

    Use this script to upload files. As a file is selected, another input field is automatically added.

  • Text Limit
    May 21, 2008

    This script will only allow a set number of characters to be entered into a text field and then focus on the next element. Easy to implement.

  • Number Formatting
    Justin Barlow May 12, 2008

    These two functions clean up and format numbers quite nicely. One function takes any decimal number, negative or positive, and formats it by adding commas every three digits. The other function strips any non-numeric characters from a string leaving you with a valid decimal number. It considers the minus sign and the period to be numeric and will not strip them unless the minus sign is not at the beginning of the number or there is more than one period. These functions make use of regular expressions to do the heavy lifting.

  • Form Field Hints
    CSS Guy May 5, 2008

    This is a basic example of how helpful a little JavaScript and CSS can be in a form.

  • Virtual Keyboard Interface
    Apr 18, 2008

    This script is a reusable system for adding a graphical keyboard interface to text fields, password fields, and textareas so they can be filled with mouse only. It also adds easy access to special characters your existing keyboard may not otherwise have the ability to generate. Comes with Arabic, Belgian, Dutch, Dvorak, French, German, Greek, Hebrew, Hungarian, Italian, Lithuanian, Norwegian, Number Pad, Polish Programmers, Portuguese, Russian, Slovenian, Spanish (Spain), Turkish-F, Turkish-QWERTY, UK, US Standard and US International keyboard layouts, dynamically selectable. Add additional layouts is simple. Easily implemented on any Web site.

  • Auto Sum Checkboxes
    Jay Rumsey Apr 4, 2008

    As the user selects items in the form, this script will display a running total automatically. No need to keep reloading the page, and no surprises for your user at the check-out point. Easy to implement into your existing forms.

  • Field Show 2
    Mar 31, 2008

    If you need to gather additional information from your visitors/customers, this script will dynamically add an input box directly after a checkbox. This will help to keep your forms neat and clean.

  • Dynamic Drop Down List
    Sandeep Gangadharan Mar 26, 2008

    Use this script when you need to offer multiple choices in your forms. Clicking a link dynamically changes the contents of the accompanying drop down list. Add as many options as you need. Complete details are explained in the script.

  • Right Click Context Menu
    Rao Vedavyas Mar 25, 2008

    "This javascript enables you to display a context menu whenever a user right click the page. It's a customizable menu. Check it out yourself... (Download Zip file)"

  • Currency Fields
    Pavel Donchev Mar 10, 2008

    This script will format designated form fields as currency fields. Can be used several times on the page. Automatically does all the formatting. Easy to use!

  • Creating Form Elements
    Matt Murphy Jan 16, 2008

    This script will generate various bug-free form elements with name attributes, selected options, and more for IE 6+, Firefox, Opera and Safari.

  • Limit Textarea 2
    Ilya Gerasimenko Jan 9, 2008

    This script limits text input to 20 characters per line for a total of 10 lines. Numbers are adjustable. It also filters textarea input: replaces non-alphanumeric characters with spaces, removes extra spaces (multiple consecutive, leading and trailing) and blank lines. Final clean-up is performed onblur, when user clicks out of textarea.

  • TextArea Character Counter
    Lefteris Haritou Jan 7, 2008

    This example counts the number of words and characters in the form textarea.

  • Auto-Enter Current Date
    Jean May Jan 4, 2008

    This script will enter the current date in a read only form field. Good for when you want to collect the current date but want to make sure it's formatted properly.

  • Pop Over Form
    Roderick Divilbiss Dec 28, 2007

    Use this script to create a form that will open on top of the existing page, using a hidden DIV. A default link is included to allow for JavaScript being turned off or unavailable.

  • DS Snow
    Dario Sciacca Dec 20, 2007

    This script displays a snow effect. The script includes a HTML code generator that allows to change parameters without any knowledge of JavaScript and HTML programming.

  • Numbers Only
    Dec 7, 2007

    Use this script to restrict the user from entering anything but numbers in a form field.

  • Outsmart Google's Toolbar
    Jon Jensen Nov 26, 2007

    Use this script to eliminate the yellow-colored fields in your forms caused by Google's AutoFill feature. Also provides a bit of info for your visitors.

  • Agree Before Posting
    Nov 16, 2007

    Sometimes you may need to make sure your visitors agree to specific terms before submitting their comments. This script will disable the input fields until they agree to your terms. Easily adaptable.

  • Verify/Notify for Duplicate Fields
    Patrick Fitzgerald Nov 14, 2007

    When requesting certain information, such as an e-mail address or a password, it's usually best to have the user enter the information twice in order to verify that a typing error did not occur. This script will do just that, and will provide a message for your user that it has been done.