1. Home
  2. Computing & Technology
  3. JavaScript

Forms

Answers to frequently asked questions on how to manipulate and validate form fields in Javascript.
Articles & Resources
Sort By : Guide Picks | Alphabetical | Recent
One Form Field with Multiple Values
Sometimes you need form fields where you want to have more than one value in the same field at the same time. This applies particularly to radio buttons and selection lists where you predefine the value(s) that you want each option to have. Some simple Javascript coding will allow you to assign as many values as you want to one form field at the same time.
Linked Dropdowns
If you have two dropdown lists in your form where selecting certain values in one list require that the same value be selected in the second list then this simple Javascript will link them for you.
Limiting Selections
Grouping checkboxes and limiting the number of entries selected in each group using Javascript.
Upper and Lowercase Conversion
Convert what your visitors enter into all uppercase or all lowercase. We can even arrange to just capitalize the first letter of each word with a little more work.
Passing the Referrer in a Form
Want to know where your visitor came from before they got to the page with your form. Why not add a hidden field to the form to pass the document.referrer.
Counting Words
Have you ever thought that it would be useful to be able to count the number of words that have been typed into a text field or text area. Well here's a script that dynamically keeps track of how many words have been entered.
Convert to Roman Numerals
You can easily convert any number between 1 and 3999 into roman numerals using this simple function.
Highlighting Text
Highlighting the current text in a form field when that field gets the focus makes it easier for your visitors to replace your default entry with their text.
Disable Form Fields
Modern browsers allow you to display a form field that is "disabled" so that it can't be accessed. You can use Javascript to enable the field once the appropriate entries in other form fields have been made.
Regular Expressions
A regular expression is a pattern that uses a special syntax to describe the content of a text field. It can be used either to validate that the string contains a valid value or alternatively it can be used to format a value entered so that it matches the specified format.
First Focus
Allow your visitors to start typing into a form on your page straight away by giving the first input field the focus.
Explore JavaScript
About.com Special Features

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

Easy ways to connect two computers for networking purposes. More >

  1. Home
  2. Computing & Technology
  3. JavaScript
  4. Javascript Tutorials
  5. Forms

©2009 About.com, a part of The New York Times Company.

All rights reserved.