JSFiddle - React, Tailwind, and code Playground
HTML
<p>
Some custom wording goes here
</p>
<p>
<label>
<input type="checkbox" id="checkbox">
GDPR Checkbox
</label>
</p>
<p>
<button id="submit" type="submit" disabled>Submit</button>
</p>
JavaScript
var checkbox = document.getElementById('checkbox');
function allowRegister(checkbox, submit) {
var submit = document.getElementById('submit');
if (checkbox.checked) {
submit.disabled = false;
}
else {
submit.disabled = true;
}
}
// Initial check just incase the page gets refreshed and the form is saved
allowRegister(checkbox);
// Also execute the function when checking the checkbox
checkbox.addEventListener('change', function(){
allowRegister(this);
});