JSFiddle - React, Tailwind, and code Playground
HTML
<form onsubmit="return validateCheckboxes();">
<h4>Which things do you enjoy?</h4>
<input type='checkbox' name='2' value='12' id='2_12'>
<label for='2_12'> Breathing</label><br />
<input type='checkbox' name='2' value='13' id='2_13'>
<label for='2_13'> Watching paint dry</label><br />
<input type='checkbox' name='2' value='14' id='2_14'>
<label for='2_14'> Nothing</label><br />
<br />
<br />
<input type="button" value="Submit">
</form>
JavaScript
function validateCheckboxes() {
if (document.querySelector('.2:checked')) {
alert('something is checked');
return true;
} else {
alert('NOTHING is checked');
return false;
}
};