$ ("#<%= ibSubmit.ClientID%>").click(function() { var flag = true; //alert($("table[id^=ctl]"). length); //Create a checked arr array to store the checked status of each radiobutton var arr = new Array; $("table[id^=ctl] input[type= radio]").each(function(i) { arr.push(this.checked); });
//Then create an arrTrue array to filter false arr array
var arrTrue = new Array; $.each(arr, function(i) { if (arr[i] == true) { arrTrue.push(arr [i]); } });
//Of course, you can also use the grep function to simplify the filtering arr array operation
var groupLen = Math.floor($("table[id^=ctl ]").length 1 / 3);
//Finally, let’s be simple, just judge whether the length of arrTrue is 11.
//Because there are 33 radiobuttons in total , each group is a group of 3, and the rule is to choose 1 out of 3 in a group, //so all 11 radiobuttons must be selected. if (arrTrue.length != groupLen) { flag = false. ; } return false;
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn