title: Enable and disable required Angular JS
body: <p>im doing a form using Angular JS and i need to deactivate a few inputs in a onchange event of a option select.</p>
  
  <p>If i choose certain option i have to deactivate like 4 inputs, and by doing this im not able to sumbit the form until i write something on the inputs, so how i can deactivate those inputs and remove the required option of the inputs? in order to sumbit the remain info on the form without asking me for the deactivate inputs.</p>
  
  <p>Thanks.</p>
  
  <pre><code>&lt;?php 
      $consultar = new Consultar();
      $result    = $consultar-&gt;_ConsultartiposProcesosCobranza();
      $num_rows  = pg_num_rows($result);
  
      //Consultar OS
      $resOs     = $consultar-&gt;_ConsultarOS();
      $num_os    = pg_num_rows($resOs);
  
      //Consultar Tipo Servidor
      $resServidor = $consultar-&gt;_ConsultarTipoServidor();
      $num_servidor = pg_num_rows($resServidor);
  ?&gt;
  
  &lt;style&gt;
      .Desc   {margin-right: 12%; margin-top: 3%; text-align: center;}
      .TopMAr {margin-top: 2%;}
  &lt;/style&gt;
  
  &lt;div class="col-xs-12 col-md-12 FormularioCobranza" data-ng-app="" &gt;
      &lt;h2 class="text-center"&gt;Formulario ejecutables Cobranza&lt;/h2&gt;
      &lt;div class="col-xs-12 alert alert-success text-center" id="AlertAgregar" style="display:none;"&gt; 
          &lt;label class="text-center"&gt;Servidor Agregado&lt;/label&gt;
      &lt;/div&gt;&lt;!-- AlertAgregar--&gt;
  
      &lt;form id="form" name="form"&gt;    
  
  
          &lt;div class="col-xs-4" ng-class="{ 'has-success': form.num_servidor.$valid}"&gt; 
              &lt;label&gt;Servidor: &lt;/label&gt;
              &lt;input type="text" placeholder="número de Servidor" class="form-control" name="num_servidor" id="num_servidor" 
              required ng-model="usuario.num_servidor" &gt;
              &lt;div class="col-xs-6 IzquierdaEspacio" ng-show="form.num_servidor.$dirty " style="position: absolute;" id="servidor_valid"&gt;
                  &lt;p class="help-block text-danger" ng-show="form.num_servidor.$error.required"&gt; Campo Obligatorio&lt;/p&gt;
              &lt;/div&gt;  
          &lt;/div&gt;
  
          &lt;div class="col-xs-4" ng-class="{ 'has-success': form.num_discoduro.$valid}"&gt; 
              &lt;label&gt;Disco Duro: &lt;/label&gt;
              &lt;input type="text" placeholder="Cantidad En GB" class="form-control" name="num_discoduro" id="num_discoduro" 
              required  ng-model="usuario.num_discoduro" &gt;
              &lt;div class="col-xs-6 IzquierdaEspacio" ng-show="form.num_discoduro.$dirty " style="position: absolute;"&gt;
                  &lt;p class="help-block text-danger" ng-show="form.num_discoduro.$error.required"&gt; Campo Obligatorio&lt;/p&gt;
              &lt;/div&gt;  
          &lt;/div&gt;
  
          &lt;div class="col-xs-4" ng-class="{ 'has-success': form.num_ram.$valid}"&gt; 
              &lt;label&gt;Ram: &lt;/label&gt;
              &lt;input type="text" placeholder="Cantidad En GB" class="form-control" name="num_ram" id="num_ram" 
              required ng-model="usuario.num_ram" &gt;
              &lt;div class="col-xs-6 IzquierdaEspacio" ng-show="form.num_ram.$dirty " style="position: absolute;"&gt;
                  &lt;p class="help-block text-danger" ng-show="form.num_ram.$error.required"&gt; Campo Obligatorio&lt;/p&gt;
              &lt;/div&gt;  
          &lt;/div&gt;
  
          &lt;div class="col-xs-4 TopMAr" ng-class="{ 'has-success': form.num_discoactual.$valid}"&gt; 
              &lt;label&gt;Disco Duro Usado: &lt;/label&gt;
              &lt;input type="text" placeholder="Cantidad En GB" class="form-control" name="num_discoactual" id="num_discoactual" 
              required ng-model="usuario.num_discoactual" &gt;
              &lt;div class="col-xs-6 IzquierdaEspacio" ng-show="form.num_discoactual.$dirty " style="position: absolute;"&gt;
                  &lt;p class="help-block text-danger" ng-show="form.num_discoactual.$error.required"&gt; Campo Obligatorio&lt;/p&gt;
              &lt;/div&gt;  
          &lt;/div&gt;
  
          &lt;div class="col-xs-4 TopMAr" ng-class="{ 'has-success': form.num_ramactual.$valid}"&gt; 
              &lt;label&gt;Ram Usado: &lt;/label&gt;
              &lt;input type="text" placeholder="Cantidad En GB" class="form-control" name="num_ramactual" id="num_ramactual" 
              required ng-model="usuario.num_ramactual" &gt;
              &lt;div class="col-xs-6 IzquierdaEspacio" ng-show="form.num_ramactual.$dirty " style="position: absolute;"&gt;
                  &lt;p class="help-block text-danger" ng-show="form.num_ramactual.$error.required"&gt; Campo Obligatorio&lt;/p&gt;
              &lt;/div&gt;  
          &lt;/div&gt;
  
          &lt;div class="col-xs-4 TopMAr" ng-class="{ 'has-success': form.id_os.$valid}"&gt; 
              &lt;label&gt;Sistema Operativo: &lt;/label&gt;
              &lt;select class="form-control" id="id_os" name="id_os" required ng-model="usuario.id_os"&gt;
                  &lt;option value=""&gt;Seleccionar...&lt;/option&gt;
                  &lt;?php 
                      for($i=0; $i&lt;$num_os; $i++)
                      {
                          $filaOs = pg_fetch_array($resOs);
                          $nb_os  = $filaOs['desc_osc'];
                          $id_os  = $filaOs['id'];
  
                          echo '&lt;option value="'.$id_os.'"&gt;'.$nb_os.'&lt;/option&gt;';
                      }
                  ?&gt;
              &lt;/select&gt;
              &lt;div class="col-xs-6 IzquierdaEspacio" ng-show="form.id_os.$dirty " style="position: absolute;"&gt;
                  &lt;p class="help-block text-danger" ng-show="form.id_os.$error.required"&gt; Campo Obligatorio&lt;/p&gt;
              &lt;/div&gt;  
          &lt;/div&gt;
  
          &lt;div class="col-xs-4 TopMAr" ng-class="{ 'has-success': form.id_servidor.$valid}"&gt; 
              &lt;label&gt;Tipo: &lt;/label&gt;
              &lt;select class="form-control" id="id_servidor" name="id_servidor" required ng-model="usuario.id_servidor" onchange="VerificarTipoServidor(this)"&gt;
                  &lt;option value=""&gt;Seleccionar...&lt;/option&gt;
                  &lt;?php 
                      for($i=0; $i&lt;$num_servidor; $i++)
                      {
                          $filas       = pg_fetch_array($resServidor);
                          $desc_ser    = $filas['desc_servidor'];
                          $id_servidor = $filas['id'];
  
                          echo '&lt;option value="'.$id_servidor.'"&gt;'.$desc_ser.'&lt;/option&gt;';
                      }
                  ?&gt;
              &lt;/select&gt;
              &lt;div class="col-xs-6 IzquierdaEspacio" ng-show="form.id_servidor.$dirty " style="position: absolute;"&gt;
                  &lt;p class="help-block text-danger" ng-show="form.id_servidor.$error.required"&gt; Campo Obligatorio&lt;/p&gt;
              &lt;/div&gt;  
          &lt;/div&gt;
  
          &lt;div class="col-xs-12" style="margin-top:3%"&gt;   
              &lt;div class="col-xs-5 pull-right" style="margin-right: 14%;"&gt;
                  &lt;input type="button" value="Cancelar" id="btn-danger" onclick="Cancelar()" class="btn btn-danger"&gt;
                  &lt;input type="button" value="Enviar" id="btn-cobranza" onclick="GuardarEjecutable()" class="btn btn-success" ng-disabled="form.$invalid"&gt;
                  &lt;!--&lt;input type="button" value="Enviar" id="btn-cobranza" ng-click="usuarios(usuario)" class="btn btn-success"&gt;--&gt;
              &lt;/div&gt;
          &lt;/div&gt;
      &lt;/form&gt; 
  &lt;/div&gt;&lt;!-- añadir cobranza--&gt;
  </code></pre>
  
  <p>function VerificarTipoServidor(input)
      {
          Option = $(input).find("option:selected").text();
          console.log(Option);
          if(Option=="PBX")
          {
              //Desabilitando los inputs
              $("#num_discoduro").prop("readonly",true);
              //$("#num_ram").prop("readonly",true);
              //$("#num_discoactual").prop("readonly",true);
              //$("#num_ramactual").prop("readonly",true);</p>
  
  <pre><code>        //Pruebas
          $("#num_discoduro").removeAttr("required");
          $("#num_ram").removeAttr("required");
          $("#num_discoactual").removeAttr("required");
          $("#num_ramactual").removeAttr("required");
  
          $("#num_discoduro").val("200");
          $("#num_ram").val("200");
          $("#num_discoactual").val("200");
          $("#num_ramactual").val("200");
  
      }//if
      else
      {
          $("#num_discoduro").prop("disabled",false);
          $("#num_ram").prop("disabled",false);
          $("#num_discoactual").prop("disabled",false);
          $("#num_ramactual").prop("disabled",false);
      }//else
  }//VerificarTipoServidor
  </code></pre>