oncheck listener for checkbox in javascript
You can do this for the input:
<input type='checkbox' onchange='handleChange(this);'>Checkbox
And this for enabling the button:
function handleChange(checkbox) {
if(checkbox.checked == true){
document.getElementById("submit").removeAttribute("disabled");
}else{
document.getElementById("submit").setAttribute("disabled", "disabled");
}
}
Try Below for your requirement using jQuery.
$('#checky').click(function(){
if($(this).attr('checked') == false){
$('#postme').attr("disabled","disabled");
}
else {
$('#postme').removeAttr('disabled');
}
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js"></script>
<input type="checkbox" checked="checked" id="checky"><a href="#">I agree to keep my Username and Password confidential and uphold
the integrity of this pharmacy</a>
<br>
<input type="submit" id="postme" value="submit">
Using JavaScript, Please refer This