Friday, May 30, 2014

Enable a button on check box checked without page refresh

In this tutorial I will show you how to enable a button on checking of a check box without using any update panel.  This is i found when I wanted to enable a register button in an registration form using update panel and the Css of the button was not working when it is disable.

So lets create a new project. And add a new check box and a button into a new web form.

<asp:CheckBox ID="chkTermsCondition" runat="server" Text="Check now"/></a>
<asp:Button ID="btnRegister" runat="server" Text="Register" 
onclick="btnRegister_Click" class="contact-button" />

Now in the head section add a java script code to do the action.

<script type="text/javascript" src="">
<script  type="text/javascript" >
    $(function () {
        var $btn = $(":submit[id$=btnRegister]");
        var $chk = $(":input:CheckBox[id$=chkTermsCondition]");
        // check on page load
        $ () {
        function checkChecked(chkBox) {
            if ($':checked')) {
            else {
                $btn.attr('disabled', 'disabled')

Add Jquery plugin to your project or add Google, Jquery online plugin. And now run the project and test. Enjoy...  :)


Post a Comment

Popular Posts