How to check if checkbox is checked using angularjs or javascript

Published on Author Code Father

checked is boolean property so you can directly use it in IF condition:-

<script type=text/javascript>
function validateCk(){
if (document.getElementById('remember').checked){
          alert("checked");} 
else{
alert("You didn't check it! Let me check it for you.")}}


</script>

<input id="remember" name="remember" type="checkbox" onclick="validateCk()" />

Comments

comments