vendredi 30 avril 2021

How to check at least one selected checkbox using form validation jquery?

html

<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script src="/jquery-ui.js"></script>
<body>
    <form id="applicationForm" method="POST" class="valida en" action="../../lib/air-condition-request.php">
    <label class="serviceDay">
    <input type="checkbox" id="airConDaily">Daily 
    <input type="checkbox" id="airConMon" name="monday" value="1">Monday
    <input type="checkbox" id="airConTue" name="tuesday" value='1'>Tuesday
    <input type="checkbox" id="airConWed" name="wednesday" value='1'>Wednesday
    <input type="checkbox" id="airConThur" name="thursday" value='1'>Thursday
    <input type="checkbox" id="airConFri" name="friday" value='1'>Friday
    <input type="checkbox" id="airConSat" name="saturday" value='1'>Saturday
    <input type="checkbox" id="airConSun" name="sunday" value='1'>Sunday
    <input type="checkbox" id="airConPh" name="ph" value='1'> Public Holiday
    </label>
    <input type="hidden" name="type" value="2">
    <input type="submit" name="button" id="button" value="Submit" class="all-btn">
    </form>
<script src="https://cdn.jsdelivr.net/npm/jquery-validation@1.17.0/dist/jquery.validate.js"></script>
<script src="../../js/form-validation.js"></script>
</body>
                  

form-validation jquery

$('#itemForm').validate({
  errorClass:"validationError",
    rules:{
    
    },
    messages:{
      
    }
  

});

Hello all,

I check many answers about at least one selected checkbox but they cannot solve my question.

How the system shows error if the the user does not choose any checkbox.

Thank you




Aucun commentaire:

Enregistrer un commentaire