mercredi 27 octobre 2021

I am using a simple checkbox in VUE JS but validation rule is not working

I am using a simple checkbox in VUE JS but validation rule is not working Checkbox Code

<div v-for="option in question.options" :key="reg.id+m+question.id+option.id">
    <input type="checkbox" v-model="attendees[reg.id]['registration'][m].questions[question.id]" :rules="[ (value) => { return ( questionsRequiredRuleCheckBoxes( value, question.required, attendees[reg.id] ['registration'][m].questions[question.id] ) ) } ]" :value="option.id" />
    <label style="padding:10px;"></label> 
</div>

validation rule

questionsRequiredRuleCheckBoxes: ( value, required, v_model ) => {
if( required != 1 ) return true;
    
   if( required == 1 && v_model.length >= 1 ) return true;
    
   if( required == 1 && v_model.length == 0 ) {
       return "At least one item is required.";
    }
}



Aucun commentaire:

Enregistrer un commentaire