<?= $this -> Form -> create('',['type' => 'get','url' => ['action' => 'action']])?>
<?= $this -> Form -> checkbox("select.check1",array('class'=> 'select')) ?>りんご
<?= $this -> Form -> checkbox("select.check2",array('class'=> 'select')) ?>バナナ
<?= $this -> Form -> checkbox("select.check3",array('class'=> 'select')) ?>みかん
<?= $this -> Form -> button('submit',array('type' => 'submit')) ?>
<?= $this -> Form - > end(); ?>
$(function() {
"use strict";
$('form').submit(function() {
if($('.select:checked').val() !== '1' ) {
window.alert('ジャンルを選択してください。');
return false;
}
}).get();
});
qiita.com