JSFiddle - React, Tailwind, and code Playground
HTML
<form id="myform" onsubmit="return checkcheckboxes()">task 1
<input type="checkbox" name="chk1" />
<br />task 2
<input type="checkbox" name="chk2" />
<br />task 3
<input type="checkbox" name="chk3" />
<br />
<br />
<input type="submit" value="Go to the next task" />
<br />
<span id="message"></span>
</form>
JavaScript
function checkcheckboxes() {
var valid = true;
var inputs = document.getElementById("myform").getElementsByTagName("input");
for (var i = 0; i < inputs.length; i++) {
if (inputs[i].type == "checkbox") {
if (!inputs[i].checked) {
valid = false;
break; // break as soon as it finds an unchecked
}
}
}
if (!valid) {
document.getElementById("message").innerHTML = "You must check all boxes to proceed";
} else {
document.getElementById("message").innerHTML = "congratulations! you have completed all the tasks completely and <a href='http://www.google.com'>here is the link</a>.";
}
return false;
}