Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6735895
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T11:04:00+00:00 2026-05-26T11:04:00+00:00

I am using position absolute’s validation engine for my form. I would like to

  • 0

I am using position absolute’s validation engine for my form. I would like to check whether at least one checkbox from group is selected. In examples it is done by setting the same name attribute for group of checkboxes.
I cannot name checkboxes with the same name, because I am saving their state in database with following code:

$values = array(
    'checkbox1'         => null,
    'checkbox2'         => null
);

foreach (array_intersect_key($_POST, $values) as $key => $value) {
    $values[$key] = mysql_real_escape_string($value);
}

$query_add_candidate=sprintf("INSERT INTO dbase (checkbox1, checkbox2)    VALUES    ('$values[checkbox1]', '$dates[checkbox2]')"

Now checkbox1 and checkbox2 are validated individually, beacuse they have different names. How can I check if selected is at least one of them?

Here is my HTML code:

<input class="validate[minCheckbox[1]] checkbox" type="checkbox" name="checkbox1" id="maxcheck1" value="1"/> Text1
<input class="validate[minCheckbox[1]] checkbox" type="checkbox" name="checkbox2" id="maxcheck2" value="2"/> Text2
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T11:04:00+00:00Added an answer on May 26, 2026 at 11:04 am

    on php ,

    if(!$_POST['checkbox1'] && !$_POST['checkbox2']){
        echo 'Error check at least one';
    }
    

    but what you really want is an array,
    HTML,

    <input type="checkbox" value="ch1" name="check[]" /> 
    <input type="checkbox" value="ch2" name="check[]" />
    

    php

    <?php 
    if(empty($_POST['check'])){
     echo 'Error: hey, check at least one will you!?'; 
    }
    
    ?>
    

    so this way you don’t have to check all of them one by one, especially if you have loads of them on the same page.

    NOTICE: You should also know, if checkbox is not ticked it will also not be set on the php $_POST superglobal, otherwise if it is ticked, it will show whatever the value="..." holds,

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Iam using this Formplugin engine for Validation http://www.position-absolute.com/articles/jquery-form-validator-because-form-validation-is-a-mess/ it has method such as noSpecialCaracters
I'm using this script ( http://www.position-absolute.com/articles/jquery-form-validator-because-form-validation-is-a-mess/ ) to valdate my form etc, which also
I am using this form validator (http://www.position-absolute.com/articles/jquery-form-validator-because-form-validation-is-a-mess/) and am having issues getting it to
http://www.position-absolute.com/articles/jquery-form-validator-because-form-validation-is-a-mess/ Iam using this form plugin.where we can call Separate function inorder to do
Usually I would do this by either setting the margin to auto, using position:absolute,
I have an image(a map) with some points of interest placed using position: absolute
i'm having the following markup using 2 divs. the #child div has set position:absolute;
How do I check if browser supports position:fixed using jQuery. I assume I have
Im using position absolute to give the top left corner of a DIV a
I am using Position Absolute's jQuery validationEngine but I need to remove it after

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.