mardi 8 novembre 2016

conditionally enable button with jQuery

<div class="error-message"></div>

 <form id="satisfaction" onsubmit="return validateInput()">
  <input type="radio" name="satisfied"  value="yes" required /> Satisfied
 <input type="checkbox" name="donate" /> Donate<br />
<input type="radio"  name="satisfied" value="no" required /> Not satisfied
    <input type="text" name="reason" /> Reason<br />
   <input type="submit" value="Submit" />
  </form>
  <script>

$('input[name="donate"]').attr('disabled', 'true');

$(document).ready(function () { $('input[name="satisfied"]').click(function(){

$('input[name="donate"]').removeAttr("disabled");

});});

How can I write a code in jQuery that lets the user check the "donate" button if and only if the "satisfied" button is checked?

Aucun commentaire:

Enregistrer un commentaire