i have some dynamically checkbox i have only checkbox checked maximum 3.However, if the fourth checkbox is checked, it should be skipped. and also have unchecked the fourth check box. my problem is all check box is unchecked.
$(document).ready(function(){
$(":checkbox").change(function() {
if(this.checked) {
var numberOfChecked = $('input:checkbox:checked').length;
if(numberOfChecked > 3 ){
alert("Maxium Allowed 3 in Slider") ;
$(":checkbox").prop("checked", false);
return ;
}
}
});
});
i need only 3 check box checking
I have a bike: <input type="checkbox" name="vehicle" value="Bike"><br>
I have a car: <input type="checkbox" name="vehicle" value="Car"><br>
I have a bus: <input type="checkbox" name="vehicle" value="Car"><br>
I have a mobile: <input type="checkbox" name="vehicle" value="Car"><br>
I have an airplane: <input type="checkbox" name="vehicle" value="Airplane">
Aucun commentaire:
Enregistrer un commentaire