SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member
    Join Date
    Jul 2003
    Location
    Hawaii
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Validating Radio and Checkboxes

    Hello Board,

    I am trying to achieve the following. I have a 3 groups which consists of 1 set of checkboxes and 2 sets of radio buttons. What I would like to do is make sure the user checks at least 1 button and 1 checkbox from each group. Can someone shoot me an example of how to achieve this?

    Thanks,

    -Ifirit

  2. #2
    SitePoint Guru Vincent Puglia's Avatar
    Join Date
    Feb 2000
    Location
    where the World once stood
    Posts
    700
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi,

    The easiest method would be to set defaults by making one of each group preselected (a no-thank-you choice, preferably. In case of the radios, the user can't unselect without selecting something else. Which means the only real problem is the checkbox group -- Essentially, somewhere along the line (within the validation/submission routine), you need to loop through the checkboxes and see if one is checked. If not, cancel submission and alert the user.

    If interested, there are a number of checkbox/radio validation routines at my site (GrassBlade)

    Vinny
    Where the World Once Stood
    the blades of grass
    cut me still


Bookmarks

Posting Permissions

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