通过样式class 判断多个checkbox redio 是否都选中
var count = "${count}"; for(var i=1;i<=count;i++){ var flag = false; if($("input[class='optionId"+i+"']:checked").length > 0){ flag = true; } if(flag==false){ alert("第 "+i+" 题未作答,请选择答案!"); return false; } }
<c:forEach items="${list}" var="risk" varStatus="status"> <div class="pg_item"> <div class="pgt_bt"> ${status.index+1}、<input type="text" name="title" value="${risk.title }" /> <input type="hidden" name="stemId" value="${risk.id }" /> <input type="hidden" name="type" value="${risk.type }" /> </div> <c:forEach items="${risk.option}" var="option" varStatus="optionStatus"> <label class="pgt_list"> <c:if test="${risk.type == 1}"> <input type="radio" name="optionId${status.index}" class="optionId${status.index+1}" value="${option.id}">${option.content} </c:if> <c:if test="${risk.type == 2}"> <input type="checkbox" name="optionId${status.index}" class="optionId${status.index+1}" value="${option.id}">${option.content} </c:if> </label> </c:forEach> </div> </c:forEach>
通过class判断 form提交时是通过 name提交
posted on 2016-11-23 17:00 weiguoyuan 阅读(495) 评论(0) 编辑 收藏 举报