Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Oct 2010
    Posts
    99
    Thanks
    10
    Thanked 1 Time in 1 Post

    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?

  • #2
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,310
    Thanks
    203
    Thanked 2,563 Times in 2,541 Posts
    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.

  • #3
    New Coder
    Join Date
    Oct 2010
    Posts
    99
    Thanks
    10
    Thanked 1 Time in 1 Post
    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.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •