disable input if select option checked

Solutions on MaxInterview for disable input if select option checked by the best coders in the world

showing results for - "disable input if select option checked"
Mads
06 Jun 2017
1  <select id="select">
2      <option value="">select this </option>
3      <option> 1 </option>
4      <option> 2 </option>
5      <option> 3 </option>
6  </select>
7   
8  <input disabled type="text" id="p_amount">
9  <input disabled type="text" id="pay_full">
10
11$("#select").change(function(){
12        if ($(this).val() !== "") {
13         $("#p_amount").prop('disabled', false);
14         $("#pay_full").prop('disabled', false);
15         }
16        else {
17         $("#p_amount").prop('disabled', true);
18         $("#pay_full").prop('disabled', true);
19       
20       //i means this value of select_option  is empty
21
22        }
23  });
Maja
31 Apr 2019
1$(document).ready(function(){
2  $("select.form-control").change(function(){
3    $(".home").prop('disabled', $(this).val() == 'home-none');
4  });
5});
6<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
7<select class="form-control">
8    <option value="home-none">-</option>
9    <option value="home-select">Team</option>
10</select>
11
12<div class="form-group">
13    <input class="form-control home" name="h-p1-fn" placeholder="First name" type="text"/>
14</div>
15<div class="form-group">
16    <input class="form-control home" name="h-p1-ln" placeholder="Last name" type="text"/>
17</div>