JSFiddle - React, Tailwind, and code Playground
HTML
<form action="http://google.com" name="testForm" id="latest">
<div>
<label for="confirm" class="fixedwidth">Yes I confirm all my details are correct</label>
<input type="checkbox" name="confirm" id="latest1" />
</div>
<div class="button">
<input type="submit" value="SUBMIT" />
</div>
</form>
JavaScript
document.getElementById("latest").onsubmit = function () {
var send = document.getElementById("latest1"),
sendValue = send.value,
sendCheck = send.checked,
errors = "";
//validate checkbox
if (!sendCheck) {
errors += "Please tick the checkbox as confirmation your details are correct \n";
}
//validate other stuff here
//in case you added more error types above
//stacked all errors and in the end, show them
if (errors != "") {
alert(errors);
return false; //if return, below code will not run
}
//passed all validations, then it's ok
alert("Your details are being sent"); // <- had a missing " after sent.
return true; //will submit
}