Answers for "Disable input if select option checked"

0

Disable input if select option checked

$(document).ready(function(){
  $("select.form-control").change(function(){
    $(".home").prop('disabled', $(this).val() == 'home-none');
  });
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<select class="form-control">
    <option value="home-none">-</option>
    <option value="home-select">Team</option>
</select>

<div class="form-group">
    <input class="form-control home" name="h-p1-fn" placeholder="First name" type="text"/>
</div>
<div class="form-group">
    <input class="form-control home" name="h-p1-ln" placeholder="Last name" type="text"/>
</div>
Posted by: Guest on October-12-2020
0

Disable input if select option checked

<select id="select">
      <option value="">select this </option>
      <option> 1 </option>
      <option> 2 </option>
      <option> 3 </option>
  </select>
   
  <input disabled type="text" id="p_amount">
  <input disabled type="text" id="pay_full">

$("#select").change(function(){
        if ($(this).val() !== "") {
         $("#p_amount").prop('disabled', false);
         $("#pay_full").prop('disabled', false);
         }
        else {
         $("#p_amount").prop('disabled', true);
         $("#pay_full").prop('disabled', true);
       
       //i means this value of select_option  is empty

        }
  });
Posted by: Guest on October-12-2020

Code answers related to "Disable input if select option checked"

Browse Popular Code Answers by Language