Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 12-08-2010, 06:37 PM   PM User | #1
rtown
New Coder

 
Join Date: Oct 2010
Posts: 92
Thanks: 10
Thanked 1 Time in 1 Post
rtown is an unknown quantity at this point
Checkbox validation help!

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)

Code:
<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?
rtown is offline   Reply With Quote
Old 12-08-2010, 07:33 PM   PM User | #2
Philip M
Supreme Master coder!

 
Philip M's Avatar
 
Join Date: Jun 2002
Location: London, England
Posts: 17,042
Thanks: 197
Thanked 2,412 Times in 2,390 Posts
Philip M has a spectacular aura aboutPhilip M has a spectacular aura aboutPhilip M has a spectacular aura about
Quote:
Originally Posted by rtown View Post
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.
Philip M is online now   Reply With Quote
Old 12-08-2010, 07:39 PM   PM User | #3
rtown
New Coder

 
Join Date: Oct 2010
Posts: 92
Thanks: 10
Thanked 1 Time in 1 Post
rtown is an unknown quantity at this point
Quote:
Originally Posted by Philip M View Post
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.
rtown is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 05:49 PM.


Advertisement
Log in to turn off these ads.