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 8357635
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T10:32:31+00:00 2026-06-09T10:32:31+00:00

I have got a checkbox group control that I want to require the user

  • 0

I have got a checkbox group control that I want to require the user to check at least ONE box, it does not matter if they check every single one, or 3, or even just one.

View code
 ---------
 <% foreach (var item in Model)
             { %>  

                  <%:Html.CheckBox("EmployeId", new { value = item.EmployeeID,@class="required"})%>
                   <span class="field-validation-valid" id="Span1"></span>

                  <%:Html.LabelForModel(item.EmployeeName)%>
                  </div>
                 <%-- <%= Html.CheckBox("Accept", new { @class = "required" })%> 
                  <span class="field-validation-valid" id="Accept_validationMessage"></span>--%> 
          <%} %>                

    </fieldset> 
    <div class="assign_button">

Can anyone please give me some help with this?

  • 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-06-09T10:32:32+00:00Added an answer on June 9, 2026 at 10:32 am

    Please call following method whereever you want to validate it. Change Checkbox class name and div name as per your implementation.

    function ValidateCheckBoxCheckedOrNot()
        {
            var selectedCheckBoxesValue = '';
    
            $('#DIVID').find("input:checkbox.CheckBoxClassName:checked").each(function (i, selected) {
                                                                if (selectedCheckBoxesValue.length == 0) {
                                                                    selectedCheckBoxesValue += $(selected).val();
                                                                }
                                                                else {
                                                                    selectedCheckBoxesValue += ',' + $(selected).val();
                                                                }});
                // Here you also get all the comma separated values if you want else use below method for it
            if(selectedCheckBoxesValue.length == 0)
            {
                alert("Select atleast one checkbox");
            }
        }
    

    or you can also do it using following way

    function ValidateCheckBoxCheckedOrNot()
        {
            var selectedCheckBoxes = $('#DIVID').find("input:checkbox.CheckBoxClassName:checked").length;
    
            if(selectedCheckBoxes==0)
            {
                alert("Select atleast one checkbox");
            }
        }
    

    EDITED POST

    <div id="CheckBoxDiv">
    <% foreach (var item in Model)
                 { %>  
    
                      <%:Html.CheckBox("EmployeId", new { value = item.EmployeeID,@class="employeeCheckBox"})%>
                       <span class="field-validation-valid" id="Span1"></span>
    
                      <%:Html.LabelForModel(item.EmployeeName)%>
                      </div>
                     <%-- <%= Html.CheckBox("Accept", new { @class = "required" })%> 
                      <span class="field-validation-valid" id="Accept_validationMessage"></span>--%> 
              <%} %> 
    </div>   
    
    <script type="text/javascript">
        //Call following method on your button click event.
        function ValidateCheckBoxCheckedOrNot()
                {
                    var selectedCheckBoxes = $('#CheckBoxDiv').find("input:checkbox.employeeCheckBox:checked").length;
    
                    if(selectedCheckBoxes==0)
                    {
                        alert("Select atleast one checkbox");
                    }
                }
    </script>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have got 2 check box[isSold(bit), Offline(bit)] in the datalist , I want to
I have got a checboxlist in edit products page, I want the checkbox list
I have got a HTML table which contain a check box in <TH> and
Have got an NSString *str = @12345.6789 and want to find out if there
I have got the requirement to find the core file in multiple box/machine and
I have got a main extending adapter which adds rows when user clicks on
I have a form where I've got three checkboxes like this: <td>Wireless <input type=checkbox
I have a cursor, and it got, lets say, 40 rows, I want to
I have created a login for an application. I got it that if you
I've got a sequence of checkboxes on a C# Winform. Each checkbox can have

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.