我如何假设我的日期的值等于 1 和总计?

How can i assume that my date when has a value is equal to 1 and total?

如果日期有值,我希望它等于 1 并将其全部相加

这是我的样本fiddleMy sample fiddle

html

$(document).ready(function(){ 
    $('[id^=total]').on('change',function() {
        var total = 0;

        $('[id^=total]').each(function(index){

            total += parseFloat($(this).val()?$(this).val():0);
        });

        var totalAll = $('#amt_due').val(total.toFixed(0));

    });
});

我希望你喜欢这样:-

$(document).ready(function(){ 
  var total = 0;
  $('input[type="date"]').on('change',function() {
    if($(this).val() == ''){
      total -=1;
    }else{
        total = $('input[type="date"]').filter(function () {return !!this.value;}).length;    
    }
    $('#amt_due').val(total.toFixed(0));
  });
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<table border="1">
  <tr>
    <td>
      <input type='date' name='total[]' id='total1' value='' />
    </td>
  </tr>
  <tr>
    <td>
      <input type='date' name='total[]' id='total2' value='' />
    </td>
  </tr>
  <tr>
    <td>
      <input type='date' name='total[]' id='total3' value='' />
    </td>
  </tr>
  <tr>
    <td>
      <input type='date' name='total[]' id='total4' value='' />
    </td>
  </tr>
  <tr>
    <td>
      <input type='date' name='total[]' id='total5' value='' />
    </td>
  </tr>
  <tr>
     <td>
       <input type="text" class="k-textbox" value="" style="color: red; text-align: right; font-family: courier" name="total_amt_due" id="amt_due" readonly="readonly" />
    </td>
  </tr>
</table>