In this article i will show code for check if checkbox is checked using jQuery or validate checkbox is checked or un-checked using jquery.
Some of my previous articles are as follows.
Jquery Code to Reset The All Div Control Height by Clicking On It , Jquery Code To Force User Accept Term and Condition , jQuery Mobile Calculator Using Jquery and HTML5, Change Textbox Background And Border Color on Focus,on Blur using jQuery In Asp.net.
So here is the code for this article.
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm3.aspx.cs" Inherits="Fileupload.WebForm3" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Code to check if checkbox is checked using jQuery | Validate checkbox is checked or un-checked</title>
<script src="http://code.jquery.com/jquery-1.8.3.js"></script>
<script>
function ValidateCheckBox() {
var status = $("#chkvalidate").attr(`checked`);
if (status == "checked") {
alert("CHECKED");
} else {
alert("UN-CHECKED");
}
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<p><input type="checkbox" id="chkvalidate" />
<input type="button" value="Click Me" onclick="javascript:ValidateCheckBox();"/>
</div>
</form>
</body>
</html>
Here in this if check box is checked on that case our variable return `checked` other wise we will get `undefined`.
OUTPUT

Thanks ... :)