체크박스 필수로 만드는 방법
본문
<p class="qna_privacy_agree">
<input type="checkbox" id="pv_agree" name="pv_agree" class="agree_ck" />
<label for="pv_agree" >동의합니다.</label>
</p>
필수로 만드는 소스좀 알려주세요 ㅠㅠ
답변 2
<input type="checkbox" id="pv_agree" name="pv_agree" required class="agree_ck" />
아니면 이것도 참고하시고..
http://gnustudy.com/bbs/board.php?bo_table=skin_board&wr_id=136
예제
<form name="thisForm">
<p class="qna_privacy_agree">
<input type="checkbox" id="pv_agree" name="pv_agree" class="agree_ck" />
<label for="pv_agree" >동의합니다.</label>
</p>
<button type="button" onClick="chk();">확인</button>
</form>
<script>
function chk() {
var f = document.thisForm;
if(f.pv_agree.checked!==true) {
alert('필수항목에 체크해 주세요.');
} else {
alert('통과');
f.submit();
}
}
</script>
답변을 작성하시기 전에 로그인 해주세요.