<div class="newfile" >
<ul>
<li><input value="test1" type="radio" name="abc" onclick="getResults()" /></li>
<li><input value="test2" type="radio" name ="abc" onclick="getResults()" /></li>
<li><input value="test1" type="radio" name ="xyz" onclick="getResults()"/></li>
<li><input value="test2" type="radio" name="xyz" onclick="getResults()" /></li>
</ul>
</div>
This is my html now i want if any two radio button having same value like ="test2" or "test1" give me alert
i tried to get value in loop
<script>
function getResults() {
var radios = document.getElementsByTagName("input");
for (var i = 0; i < radios.length; i++) {
if (radios[i].checked) {
alert(radios[i].value);
break;
}
}
}
</script>
but not getting how to compare the value of two checked button and get alert.
over i want if any two radio button having same value give me alert else nothing should happen.