JSFiddle - React, Tailwind, and code Playground

by nimeshrmr

HTML

<form id='targets' name='targets' action='http://www.innovativephp.com' method='post'  >
    
<input name="test_field" id="checkboxid" type="checkbox">I Agree to Terms of Use
    <input type='submit' value='Save' />
</form>

JavaScript

$('#targets').submit(function() {
    var error = 0;
    if (!($('#checkboxid').is(':checked'))) {
        error = 1
        alert("Please Tick the Agree to Terms of Use");
    }

    if (error) {
        return false;
    } else {
        return true;
    }

});