Sorry I'm a beginner *** I have 6 School Children id , and the teacher will put this ids or not important but he must put 1 minimum .. or when he put more of one must them be different from each other .
I used parsley.js to validate my test live here : jsfiddle
I tried to check more than 6 inputs if they are different from each other or not Because if the inputs are the same, a message appears on the similar field .. by parsley and jq . that what I did
<form action="" id="homeform" method="POST" style="width: 100%;" novalidate="novalidate">
<input type="text" class="datac selector" data-parsley-date="" name="m1" id="m1" />
<input type="text" class="datac selector" data-parsley-date="" name="m2" id="m2" />
<input type="text" class="datac selector" data-parsley-date="" name="m3" id="m3" />
<input type="text" class="datac selector" data-parsley-date="" name="m4" id="m4" />
<input type="text" class="datac selector" data-parsley-date="" name="m5" id="m5" />
<input type="text" class="datac selector" data-parsley-date="" name="m6" id="m6" />
<button id="submit" type="submit">Check Out</button>
</form>
<script type="text/javascript">
window.ParsleyValidator
.addValidator(
'date',
function(value, requirements) {
$(this).attr('value', $(this).val());
var values = []
$('.selector').each(function(){
if ($(this).val() != ''){
if(!values.includes(this.value)){
values.push(this.value)
return true;
$(this).css("border-color", "");
}else{
values.push(this.value)
$(this).css("border-color", "red");
return false;
}
}
});
},
34
)
.addMessage('en', 'date', "Enter a valid date");
</script>
and there is anyway , I can marge JavaScript with parsley validator ?