---
title: "How to check atleast one checkbox is checked?"  
description: "How to check atleast one checkbox is checked?"  
author: "Anonymous User"  
published: 2014-09-02  
updated: 2014-09-02  
canonical: https://www.mindstick.com/forum/2221/how-to-check-atleast-one-checkbox-is-checked  
category: "asp.net"  
tags: ["asp.net", "c#", ".net", "check atleast one checkbox is checked", "check checkbox is checked"]  
reading_time: 1 minute  

---

# How to check atleast one checkbox is checked?

I want to [check](https://yourviews.mindstick.com/story/2248/never-forget-to-check-these-specifications-before-buying-a-mobile-phone) at [least](https://yourviews.mindstick.com/story/1471/5-autobiographies-you-should-read-at-least-once) one [checkbox](https://www.mindstick.com/articles/291/how-should-use-checkbox-control-in-vb-dot-net) should be checked before unload the page or clicking on btn save.

<asp:[GridView](https://www.mindstick.com/articles/873/update-delete-edit-gridview-in-asp-dot-net) ID="grdTest" runat="[server](https://www.mindstick.com/articles/43769/what-is-serverless-architecture-is-it-worth-switching-over)" DataKeyNames="Id" AutoGenerateColumns="False" HorizontalAlign="Center" GridLines="None" onrowcreated="grdTest_RowCreated">

<asp:TemplateField >

<[ItemTemplate](https://www.mindstick.com/forum/2057/access-textbox-in-itemtemplate)>

<asp:[TextBox](https://www.mindstick.com/forum/12714/dynamic-textbox-in-gridview) ID="txtText" Rows="10" Columns="40" runat="server" TextMode="MultiLine" Height="55px" Text='<%# Eval("Text") %>'></asp:TextBox>

<asp:[Button](https://www.mindstick.com/articles/63/how-to-add-button-in-datagridview-in-csharp-dot-net) ID="btnSave" runat="server" Text="Save" CommandName="Save"/>

<span id="checkbox">

<asp:[RadioButton](https://www.mindstick.com/blog/233/get-checked-radiobutton-using-javascript) ID="rbtnTest" runat="server" Checked='<%# Eval("Correct") %>' [TextAlign](https://www.mindstick.com/forum/33401/textalign-not-working-in-uialertview)="Left" Height="28px" />

</span>

</ItemTemplate>

<EditItemTemplate>

<asp:TextBox ID="txtText" Rows="10" Columns="40" runat="server" TextMode="MultiLine" />

<asp:Button ID="btnSave" runat="server" Text="Save" CommandName="Save"/>

<asp:CheckBox ID="rbtnTest" runat="server" Enabled="true" TextAlign="Left"/>

</EditItemTemplate>

</asp:TemplateField>

</asp:GridView>

plz some one help me?

## Replies

### Reply by Sumit Kesarwani

Hi Ankit, try this:

<script type="text/javascript" language="javascript">

function Validate_Checkbox()

{

var chks=document.getElementsByTagName('input');

var hasChecked = false;

for (var i = 0; i < chks.length; i++)

{

if (chks[i].checked)

{

hasChecked = true;

break;

}

}

if (hasChecked == false)

{

alert("Please select at least one checkbox..!");

return false;

}

return true;

}

</script>

and on Submit Button you have to write

OnClientClick="return Validate_Checkbox()"


---

Original Source: https://www.mindstick.com/forum/2221/how-to-check-atleast-one-checkbox-is-checked

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
