lundi 26 novembre 2018

if checkbox is unchecked during form submission then it will become red

I have a register form and there I have two checkboxes. If it is unchecked and the client clicks on register button then it will become red.

Following is my checkbox codes:-

$('#age_confirmation').change(function(){
    var c = this.checked ? '' : 'red';
    $('#age_confirmation').css('color', c);
});
$('#terms_of_service').change(function(){
    var c = this.checked ? '' : 'red';
    $('#terms_of_service').css('color', c);
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<form action="" method="post" accept-charset="utf-8" class="form-signin form-register" role="form" id="register" autocomplete="off">
  <div style="display:none"></div>
  <input type="checkbox" id="age_confirmation" name="age_confirmation" required tabindex="10"/> Age Confirmation
  <input type="checkbox" id="terms_of_service" name="terms_of_service" required tabindex="11"/> Terms of Service
  <input type="submit" class="btn btn-tiffany" value="register" />
</form>

Can anyone tell me where I'm wrong. Any help will be appreciated.




Aucun commentaire:

Enregistrer un commentaire