SitePoint Sponsor

User Tag List

Results 1 to 4 of 4

Hybrid View

  1. #1
    SitePoint Enthusiast
    Join Date
    May 2007
    Posts
    33
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    checking at least 3 checkboxes have checked

    Hi

    I have about 20 checkboxes on a register page for my site. I want to make sure that at least 3 of them have been checked. How would i go about doing this?

  2. #2
    SitePoint Zealot mwasif's Avatar
    Join Date
    Apr 2007
    Location
    Pakistan
    Posts
    102
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If you have named them as checkbox_name[], then you can simply use

    PHP Code:
    if(count($_POST["checkbox_name"])<3)
    echo 
    "please select atleast 3 checkbox"

  3. #3
    SitePoint Enthusiast
    Join Date
    May 2007
    Posts
    33
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    How would I name them?

    All i've got is:

    Code:
    Choose up to 3 genres which best suit you:*<br><br>
    
    <input type="checkbox" name="rockcheck">Rock
    <input type="checkbox" name="metalcheck">Metal
    
    // etc...

  4. #4
    SitePoint Enthusiast
    Join Date
    May 2007
    Posts
    33
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Nevermind i've done it! Thanks for the reply!


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
  •