HTML:
<form id="form1" runat="server">
<div class="smallDiv">
<h2>Click on the Checkbox to Enable the Button control</h2>
<asp:CheckBox ID="cb1" runat="server"
Text="Check To Toggle the Enabled status of the Button"
Tooltip="Click Here To Enable/Disabled the CheckBox"/><br /><br />
<asp:Button ID="btnSubmit" runat="server" Text="Submit" />
</div>
</form>
Jquery Script:
<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<script>
$(function () {
var $btn = $(":submit[id$=btnSubmit]");
var $chk = $(":input:CheckBox[id$=cb1]");
// check on page load
checkChecked($chk);
$chk.click(function () {
checkChecked($chk);
});
function checkChecked(chkBox) {
if ($chk.is(':checked')) {
$btn.removeAttr('disabled');
}
else {
$btn.attr('disabled', 'disabled')
}
}
});
</script>
Tuesday, March 26, 2013
Enable/Disable ASP.NET button on CheckBox Checked/Uncheked using Jquery
Subscribe to:
Post Comments (Atom)
No comments:
Write comments