Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
JQuery to check atleast one checkbox is checked in the gridview asp.net
#1
Hi,

      Here is the Jquery code to check weather at least one checkbox is checked in the gridview column.
It is a client side validation using JQuery.


Code:
<script type="text/javascript" language="javascript">
       $(document).ready(function () {
           $('#btnDelete').click(function () {
               var chkboxrowcount = $("#<%=grdEmployeeDelete.ClientID%> input[id*='chkDelete']:checkbox:checked").size();
               if (chkboxrowcount == 0) {
                   alert("please select at least one record");
                   return false;
               }
               return true;
           });
       });
   </script>

Kindly share if you find it useful.
If you have any doubt, please comment below.

Note: I have attached the complete code with a small example, you can download and refer it.
Also subscribe and get instant updates on new posts.


Attached Files
.txt   JqueryValidation.txt (Size: 2.97 KB / Downloads: 0)
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)