html checkbox yes if checked code example

Example 1: how to make checkbox checked in html

<input type="checkbox" checked={props.completed} /> 

#for props completed is true/false , hence if completed is false then checkbox will not be clicked .
# if the checkbox is true it will be will be checked

Example 2: check if checkbox is checked javascript

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

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

Tags:

Html Example