title: Disable button using Jquery if and else function
body: <p><a href="http://i.stack.imgur.com/xqDmj.png" rel="nofollow">Screenshot</a> i want to disable my button using if and else statement. If value on the input text "Tidak Diluluskan" the button disable else text " Proses " the button enable. Here my simple code.. Hope someone can help me figure this out. </p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>&lt;script&gt;
      $(document).ready( function () {
         if(textstatusmodal.value =="Tidak Diluluskan"){
          $('button:submit').attr("disabled", 'disabled');
           }else{
             if(textstatusmodal.value =="Proses"){
               $('button:submit').attr("enable", 'enable');
               }
             }
         }
      });
      // $(this).attr("disabled", "disabled");
      //$(this).removeAttr("disabled");//enable button again
  &lt;/script</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;form method="POST" action="&lt;?php echo $editFormAction; ?&gt;" name="form2" class="form-horizontal"&gt;
  &lt;fieldset&gt;
  
   
  &lt;input id="textstatusmodal" name="textstatusmodals"  type="type" value="&lt;?php echo $row_p_peribadi_kecemasan['status']; ?&gt;"&gt; 
  
  &lt;!-- Select Basic --&gt;
  &lt;div class="form-group"&gt;
    &lt;label class="col-md-4 control-label" for="selectbasic"&gt;Pilihan&lt;/label&gt;
    &lt;div class="col-md-5"&gt;
      &lt;select id="selectbasic" name="selectbasic" required class="form-control"&gt;
        &lt;option value=""&gt;Sila Pilih&lt;/option&gt;
        &lt;option value="Batal"&gt;Batal&lt;/option&gt;
      &lt;/select&gt;
    &lt;/div&gt;
  &lt;/div&gt;
  
  &lt;!-- Textarea --&gt;
  &lt;div class="form-group"&gt;
    &lt;label class="col-md-4 control-label" for="textcatatan"&gt;Catatan&lt;/label&gt;
    &lt;div class="col-md-4"&gt;                     
      &lt;textarea class="form-control" required id="textcatatan" name="textcatatan"&gt;&lt;/textarea&gt;
    &lt;/div&gt;
  &lt;/div&gt;
  
        &lt;/div&gt;
        &lt;div class="modal-footer"&gt;
          &lt;button  id="button3" type="submit" onclick="return confirm('Batal Pegerakan Bagi No Permohonan:&lt;?php echo $row_p_peribadi_kecemasan['nopermohonan']; ?&gt;?')" class="btn btn-success"&gt;Kemaskini&lt;/button&gt;
          &lt;button id="button4" class="btn btn-info" data-dismiss="modal"&gt;Tutup&lt;/button&gt;
        &lt;/div&gt;
      &lt;/div&gt;&lt;!-- /.modal-content --&gt;
    &lt;/div&gt;&lt;!-- /.modal-dialog --&gt;
  &lt;/div&gt;&lt;!-- /.modal --&gt;</code></pre>
  </div>
  </div>
  </p>