Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <ol type="a">
- <li><input type="radio" name="answer0[]">A</li>
- <li><input type="radio" name="answer0[]">A</li>
- <li><input type="radio" name="answer0[]">A</li>
- </ol>
- <ol type="a">
- <li><input type="checkbox" name="answer1[]">A</li>
- <li><input type="checkbox" name="answer1[]">A</li>
- <li><input type="checkbox" name="answer1[]">A</li>
- </ol>
- $('ol').each(function (i) {
- $(this).find("input:first").prop("required", true);
- });
- $('ol').each(function (i) {
- $("[name='answer"+i+"[]']").rules("add", {required:true});
- });
- var rules = {};
- $('ol [type="checkbox"], ol [type="radio"]').each(function(i,el){
- var name = $(el).attr('name');
- if(rules[name] === undefined){
- rules[name] = {
- required: true
- };
- }
- });
- $("#myform").validate({
- rules: rules
- });
- $('ol').each(function (i) {
- $(this).find("input[type='checkbox']").prop("required", true);
- });
- $('ol').find('input[type="checkbox"]:checked').length
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement