Check checkbox if something is typed in a input type text - Javascript jQuery

Javascript examples for jQuery:Form Checkbox

Description

Check checkbox if something is typed in a input type text

Demo Code

ResultView the demo in separate window


<html>
 <head> 
  <script src="https://code.jquery.com/jquery-1.10.2.min.js"></script> 
 </head> /*from   w  w  w .ja  v  a2  s  .c  o m*/
 <body> 
  <input type="text" class="num"> 
  <br> 
  <input type="checkbox" name="check" class="check"> 
  <script>
$(".num").on("keyup", function(e){
  if(this.value!=""){
        $(".check").prop("checked", "checked");
  }else{
        $(".check").prop('checked', "");
  }
});

      </script>  
 </body>
</html>

Related Tutorials