You can add a click event handler to the each of the checkboxes and check if the current checkbox is checked. If not, check if any of them have been checked before and if so, use form.reset() to reset the form.
const checkboxes = document.querySelectorAll("input[type=checkbox]");
const form = document.querySelector("form");
var checkedOne = false;
Array.prototype.slice.call(checkboxes).forEach(function(checkbox) {
checkbox.addEventListener("click", function(e) {
if (this.checked) {
checkedOne = true;
} else {
if (checkedOne && !document.querySelectorAll("input[type=checkbox]:checked").length) {
form.reset();
}
}
});
});
<form>
<fieldset>
<label><input type="checkbox" name="foo">Apples</label>
<label><input type="checkbox" name="foo">Oranges</label>
</fieldset>
<fieldset>
<label><input type="radio" name="bar">Red</label>
<label><input type="radio" name="bar">Blue</label>
</fieldset>
</form>