1. Home
  2. Computing & Technology
  3. JavaScript

Radio Button Validation

1. Introduction

clr gif
Join the Discussion

Questions? Comments?

The setup and validation of radio buttons appears to be the form field that gives many webmasters the most difficulty in setting up. In actual fact the setup of these fields is the most simple of all form fields to validate as radio buttons only set one value that only needs to be tested when the form is submitted.

The difficulty with radio buttons is that there are at least two and usually more fields that need to be placed on the form that need to be related together and tested as one group. Provided that you use the correct naming conventions and layout for your buttons you will not have any trouble.

Let's begin by looking at a group of radio buttons correctly defined with a validation routine attached to the form's submit button.




The above is an example of what we want to achieve. The next step is to look at how to achieve it. Let's start by looking at defining the buttons.

1 | 2 | 3 | 4
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

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

All rights reserved.