Validation of radio and check boxes input
Below is a simple form with checkboxes and radio buttons, please fill it in.
Explanations:
- In the head, some JavaScript code that defines a "give_feedback" function is loaded
- Checkboxes are a bit more difficult to handle than radio
buttons. Also, unlike radio buttons you can choose to
differentiate between check boxes by either giving same name to
a series of checkboxes with different values or alternatively by
giving each checkbox its own name. In the latter case no value
is needed for processing, but you could give one.
-
To decide if a user checked a checkbox, you need to look at the
"checked" property. In the first case you have to retrieve the
element by an index, in the second you don't need to.
-
Radio buttons are as tricky as multiple checkboxes with the same name. To check whether the user
selected a value and at the same time to retrieve a selection we wrote a little function.
function get_selected_radio_value (list)
will take a DOM node list representing
a series of checkboxes.
- JavaScript code is inside this page ...
Validation of radio and check boxes input
Last modified: Sun May 04 20:57:08 Europe de l'Ouest (heure d'été) 2008