【jQuery】チェックが入ったらボタンクリック-複数編-【備忘録】

jQuery

<script>
function check(){

var check_count = $(‘.chk-caution01 :checked’).length;//注意事項チェック
if (check_count == 0 ){
alert(‘●●をご確認の上、チェックしてください’);return false;
}

var check_count = $(‘.chk-caution02 :checked’).length;//重要事項説明チェック
if (check_count == 0 ){
alert(‘■■をご確認の上、チェックしてください’);return false;
}
}
</script>

 

■□■html■□■

<div class=”chkbox chk-caution01″>
<input type=”checkbox” id=”note01″ name=”note01″ value=”●●について”>
<label for=”note01″>確認のうえチェックをしてお進みください。</label>
</div>

<div class=”chkbox chk-caution02″>
<input type=”checkbox” id=”note02″ name=”note02″ value=”●●について”>
<label for=”note02″>確認のうえチェックをしてお進みください。</label>
</div>

 

「.chk-caution0★」を増やし続ければいくつでも対応可能。

コメント