i have this sample html coding
<form id = "myform" onsubmit = "return checkcheckboxes()">
task 1</task><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" >congratulations! you have completed all the task completely</span>
</form>
and this is the JS
function checkcheckboxes() {
document.getElementById("message").innerHTML = "";
var valid = true;
var f = document.getElementById("myform");
if (f.chk1.checked == false) {valid = false}
if (f.chk2.checked == false) {valid = false}
if (f.chk3.checked == false) {valid = false}
if (!valid) {document.getElementById("message").innerHTML = "You must check all three boxes to proceed"};
return valid;
}
If you open the code in the browser with JS, it will show you three checkboxes with a submit button and there is a span text under submit button saying
congratulations! you have completed all the tasks completely
If you check >2 boxes and click submit, the text under the submit button will say
You must check all three boxes to proceed
and if you check all 3 boxes the message will change again back to:
congratulations! you have completed all the tasks completely
what i want to do is remove the saying:
congratulations! you have completed all the tasks completely
and only show it when all the boxes are checked and submit button is click, since is showing even though boxes are not checked.