I have a simply question but I try many things but they not working as I expect.
Problem: 1. A few checkboxes with class like "a" ,"b" ,"c" but with different id's. 2. On button click I try to validate that only one of checkboxes is checked. 3. I know only checkbox classes(The common element)
My code:
$('#submit').click(function() {
var matches = [];
var items = document.getElementsByClassName('1'); //??? if the items is null?
for (var i = 0; i < items.length; i++){
matches.push({id:items[i].id, value:items[i].value});
}
if((matches[0].id != matches[1].id) &&(matches[0].value == matches[1].value))
alert("ERROR!!!");
});
Please show me the best way to resolve that problem