카테고리 없음

<JQUERY_JSP> 입력 체크 박스 검사

달남 2019. 11. 20. 10:02

1. 체크 함수 

if( $("input[name='item']:checked").length < 3 && !$("input[name='item_all']").prop("checked") && !$("input[name='item']:checked").length == 0 ){
                alert("<spring:message code="code.m20080"/>");//재정회계지표를 3개이상 선택해주세요.     
                return;
            }   

2. JSP  태그

<tr>
<th scope="row"><spring:message code="code.m00544" /></th><%--재정회계지표 --%>
<td>
<span class="radio-check-wrap">
<input id="item_all" type="checkbox" value="" name="item_all">
<label for="item_all"><spring:message code="code.m00595" /></label><%--전체 --%>
</span>
<c:forEach items="${itemList}" varStatus="status" var="obj">
<span class="radio-check-wrap">
<input id="label_item_${status.index}"  name="item" type="checkbox" value="${obj.cd }" class="item_class">
<label for="label_item_${status.index}">${obj.nm }</label>
</span>
</c:forEach>
</td>
</tr>