title: Enable/disable button on modal pop up
body: <p>I am very new to client side programming and I am looking to solve the following issue. I have MVC cshtml page which has some information on it. On click on the Save button, there is a modal pop up that shows (attached a screen shot of it) with a check box, a text box with some text in it and save and a cancel button. Following is the html for this modal pop up. </p>
  
  <pre><code>&lt;div id="save-as-modal" class="modal fade" role="dialog"&gt;
          &lt;div class="modal-dialog"&gt;
              &lt;div class="modal-content"&gt;
                  &lt;div class="modal-header modal-header-blue"&gt;
                      &lt;button type="button" class="close" data-dismiss="modal" aria-label="Close"&gt;
                          &lt;span id="close" aria-hidden="true" class="fa fa-times"&gt;&lt;/span&gt;
                      &lt;/button&gt;
                      &lt;h4 class="modal-title"&gt;Save As...&lt;/h4&gt;
                  &lt;/div&gt;
                  &lt;div class="modal-body"&gt;
                      &lt;div class="messages"&gt;&lt;/div&gt;
                      &lt;div class="form-horizontal"&gt;
                          &lt;div class="form-group"&gt;                               
                                  &lt;input class="@Model.CheckBoxContainerDivCssClass" type="checkbox" id="chkBox"&gt;Are u sure ?&lt;br&gt;                               
                                  &lt;label class="@Model.FormLabelRequiredCssClass"&gt;Name&lt;/label&gt;
                                  &lt;div class="@Model.FormFieldEditorDivCssClass"&gt;
                                      &lt;input class="@Model.InputTextCssClass" type="text" name="name" value="" /&gt;
                                  &lt;/div&gt;
                              &lt;/div&gt;
                      &lt;/div&gt;
                  &lt;/div&gt;
                  &lt;div class="modal-footer"&gt;
                      &lt;button type="button" class="btn btn-primary save" id="btnSave"&gt;Save&lt;/button&gt;
                      &lt;button class="btn btn-default cancel"&gt;Cancel&lt;/button&gt;
                  &lt;/div&gt;
              &lt;/div&gt;
         &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>Now I would like to disable the Save button on load of this pop up, and the save button should get enabled only on checking the check box. I wrote the following Jquery for this </p>
  
  <pre><code>&lt;script&gt;
          $(document).ready(function () {           
              $('#btnSave').prop('disabled', !$('#chkBox').prop("checked"));
              $('#chkBox').on('change', function () {
                  $('#btnSave').prop('disabled', !$('#chkBox').prop("checked"));
              })
          });
  &lt;/script&gt;
  </code></pre>
  
  <p>But it does not seem to work. The button is not disabled when the pop up is seen on the screen. But on check of the check box and unchecking it .. it starts behaving the way it should as in ...enable the save button on check of the check box and disable it on un-check of it. I later on realised that the class="btn btn-primary save" being used on the Save button has something to do with this. If I removed this class on the Save button, although it does not appear to be asthetically pleasing, it works the way it is supposed to i.e. be disabled when the modal pop up appears and enable and disable the save button on check and un-check of the check box. </p>
  
  <p>The class="btn btn-primary save" has the following code for btn-primary</p>
  
  <pre><code>.btn-default, .btn-primary, .btn-success, .btn-info, .btn-warning, .btn-danger {   text-shadow: 0 -1px 0 rgba(0, 0, 0, .2);  
  -webkit-box-shadow: inset 0 1px 0 rgba(255, 255, 255, .15), 0 1px 1px rgba(0, 0, 0, .075);
            box-shadow: inset 0 1px 0 rgba(255, 255, 255, .15), 0 1px 1px rgba(0, 0, 0, .075); }
  
  .btn-primary {   background-image: -webkit-linear-gradient(top,
  #428bca 0%, #2d6ca2 100%);   background-image:         linear-gradient(to bottom, #428bca 0%, #2d6ca2 100%);   filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff428bca', endColorstr='#ff2d6ca2', GradientType=0);   filter: progid:DXImageTransform.Microsoft.gradient(enabled = false);   background-repeat: repeat-x;   border-color: #2b669a; }
  </code></pre>
  
  <p>Is there anything in this CSS which is preventing the button from getting disabled on load ? I am not sure how to make this work keeping the class="btn btn-primary save" on the button. </p>
  
  <p>Hoping for some help. </p>
  
  <p>AJ</p>