Enabling a checkbox when text inputs are not empty
I have some text inputs and one checkbox:
- <input type="text">
- <input type="text">
- <input type="text">
-
- <input type="checkbox">
I want to disable the checkbox and enable it when all text inputs will be not empty.
I have this code, but it doesn't work:
- $(document).ready(function () {
- var empty;
-
- $('input[type="checkbox"]').prop({
- disabled: true
- });
-
- $('input[type="text"]').keyup(function(){
- $('input[type="text"]').each(function(){
- if($(this).val().length == 0) {
- empty = true;
- }
- });
- });
-
- if(empty == true) {
- $('input[type="checkbox"]').prop({
- disabled: true
- });
- }
- });
Could you help me?