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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T20:03:13+00:00 2026-05-15T20:03:13+00:00

Using ASP.NET to generate several checkboxes. Looking for a JavaScript solution that will test

  • 0

Using ASP.NET to generate several checkboxes. Looking for a JavaScript solution that will test any checkbox starting with the name pdf* to see if more than 5 are checked, then alert over that number.

There are other checkboxes I do not want this to run on that do not have the name pdf*.

Thanks in advance.

here is an example of my checkboxs:

<td><input type="checkbox" name="pdf14" value="2250"></td>

<td><input type="checkbox" name="pdf15" value="2251"></td>

<td><input type="checkbox" name="pdf16" value="2252"></td>
 
<td><input type="checkbox" name="print" value="2253"></td> 

<<<NOT A PART OF THE COUNT

  • 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-15T20:03:13+00:00Added an answer on May 15, 2026 at 8:03 pm
    var inputs = document.getElementsByTagName("input");
    var numSelected = 0;
    var current;
    
    for (var i=inputs.length;i--;) {
        current = inputs[i];
    
        if (current.type.toLowerCase() == "checkbox" && current.checked && current.name.indexOf("pdf") == 0) {
            current++;
        };
    };
    
    if (current > 5) {
        alert("You've got " + current + " selected! :(");
    }
    

    If you happened to use jQuery, it’d be as easy as

    var selectedPdfCheckboxes = $('input:checkbox[name^=pdf]');
    
    if (selectedPdfCheckboxes.length > 5) {
        alert("You've got " + selectedPdfCheckboxes.length + " selected! :(");
    }
    

    Edit:

    The jQuery selector I’ve used (^=) reads as “start with”, so no * equivalent is needed.

    The jQuery code will execute wherever it is placed, however it must be executed no sooner than document.ready(), to ensure the elements you are selecting are present in the DOM. If you place it inside document.ready, it will fire as soon the document ready event is fired. You might want to place the code inside an event handler for another event.. such as the submission of a form?

    $(document).ready(function () {
        $("#aForm").bind('submit', function (e) {
            var selectedPdfCheckboxes = $('input:checkbox[name^=pdf]');
    
            if (selectedPdfCheckboxes.length > 5) {
                alert("You've got " + selectedPdfCheckboxes.length + " selected! :(");
    
                e.preventDefault();        
            }
        });
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 516k
  • Answers 516k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer There is also a second problem with your program. You… May 16, 2026 at 6:43 pm
  • Editorial Team
    Editorial Team added an answer With large and oft-changed binary files, both git and svn… May 16, 2026 at 6:43 pm
  • Editorial Team
    Editorial Team added an answer You need to edit the .state file of the CCNET… May 16, 2026 at 6:43 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

i have sql that uses FOR XM RAW to generate xml for my asp.net
I use asp.net + MVC1.0 and in a web-page I have several forms, within
I am using SqlMetal to general my DataContext.dbml class for my ASP.net application using
I'm using Asp.NET 4 with Ajax Client Templates for my homepage. The homepage generates
I'm currently developing an image viewer using asp.net MVC. The image viewer itself works
I'm using NLog in my ASP.NET application hosted on IIS and Windows server 2003.
I'm building a heavily CRUD based ASP.NET website and I've got to the phase
Currently we are working on ASP .net application and i would prefer to go
I've worked with ASP.NET once before and had a project where it was potentially
I am an asp.net web application developer and I always have used Enterprise Library

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.