...

View Full Version : Checkbox validation help!



rtown
12-08-2010, 07:37 PM
Hey guys, I am having a bit of an issue here. I have a form which has 3 checkboxes in it: (sorry, ignore the asp)


<input name="certs" id="certs" type="checkbox" <% If certs="on" Then Response.Write("checked=""checked""") %> />

<input name="nocerts" id="nocerts" type="checkbox" <% If nocerts="on" Then Response.Write("checked=""checked""") %> />

<input name="certsna" id="certsna" type="checkbox" <% If certsna="on" Then Response.Write("checked=""checked""") %> />

Anyways, I want to enforce the following:
- Only one checkbox can be checked from these 3, no more
- At least one checkbox must be checked before submission

I have found a couple small scripts to validate that at least one is pressed, but I do not know how to make sure no more than one is pressed, and how to combine scripts is beyond me. Can anyone offer any assistance? Is this difficult to do? :)

Philip M
12-08-2010, 08:33 PM
Anyways, I want to enforce the following:
- Only one checkbox can be checked from these 3, no more
- At least one checkbox must be checked before submission



If only one checkboxes in a group may be checked you should use radio buttons, not checkboxes. The whole point of checkboxes is that more than one may be selected, and the user will expect that. The whole point of radio buttons is that only one out of a group may be selected.

All advice is supplied packaged by intellectual weight, and not by volume. Contents may settle slightly in transit.

rtown
12-08-2010, 08:39 PM
If only one checkboxes in a group may be checked you should use radio buttons, not checkboxes. The whole point of checkboxes is that more than one may be selected, and the user will expect that. The whole point of radio buttons is that only one out of a group may be selected.

All advice is supplied packaged by intellectual weight, and not by volume. Contents may settle slightly in transit.

Excellent, I did not know that about radio buttons. I will change them and see what I can do. :D



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum