Quantcast
Channel: Active questions tagged html - Stack Overflow
Viewing all articles
Browse latest Browse all 67527

How to set default value of start date as yesterday and end date as today in jquery

$
0
0

I want to display default value of start_date and end_date field as yesterday and today respectively. Any help would be appreciated, thank you.

Here is my code:

$(document).ready(function () {

  $('#start_date .input-group.date').datepicker({
      startView: 1,
      todayBtn: "linked",
      keyboardNavigation: false,
      forceParse: false,
      autoclose: true,
      format: 'yyyy-mm-dd'
      default:today
  });
  $('#end_date .input-group.date').datepicker({
      startView: 1,
      todayBtn: "linked",
      keyboardNavigation: false,
      forceParse: false,
      autoclose: true,
      format: 'yyyy-mm-dd'
  });

  $('#published_date .input-group.date').datepicker({
      startView: 1,
      todayBtn: "linked",
      keyboardNavigation: false,
      forceParse: false,
      autoclose: true,
      format: 'yyyy-mm-dd'
  });

});

My HTML:

<div class="col-md-2">
  <div class="form-group" id="start_date">
    <label for="">Start Date<span style="color: red;">&nbsp;</span></label>
    <div class="input-group date">
      <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
      <input  type="text" class="form-control" required name="start_date">
    </div>
  </div>
</div>
<div class="col-md-2">
  <div class="form-group" id="end_date">
    <label for="">End Date<span style="color: red;">&nbsp;</span></label>
    <div class="input-group date">
      <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
      <input  type="text" class="form-control" required name="end_date">
    </div>
  </div>
</div>

Viewing all articles
Browse latest Browse all 67527

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>