Jquery checks whether multiple groups of radio checkboxes are selected. jquerycheckbox
A small page for a recent questionnaire survey needs to determine whether each item of the user has a choice. If each item is hard to be judged, I searched the internet and summarized it myself, I wrote a small piece of code ~ Haha, the level is limited. Sorry. The html code will not be available, and the N multi-choice and multi-choice boxes will be right...
Function validate_all () {var radioName = new Array (); $ (": radio "). each (function () {radioName. push ($ (this ). attr ("name") ;}; $ (": checkbox "). each (function () {radioName. push ($ (this ). attr ("name") ;}); radioName. sort (); $. unique (radioName); $. each (radioName, function (I, val) {if (! CheckRadio (val) {alert ("You have not selected any items. Please select one. Thank you ~ "); Return false ;}}) ;}function checkRadio (radioName) {return $ (" input [name = "+ radioName +"]: checked "). val () = null? False: true ;}
Haha, in fact, it is to get the names of all radio and checkbox, and use unique to remove duplicates after sorting sort (). It is OK to traverse the each array to check whether each name has a selected value ~