Set default Date as todays Date in jQuery DatePicker in ASP.Net MVC

Last Reply on Nov 25, 2016 02:34 AM By dharmendr

Posted on Nov 25, 2016 02:32 AM

Code behind in View

<div class="form-group col-md-6">
   @Html.LabelFor(model => model.pickupdate_, htmlAttributes: new { @class = "control-label col-md-2" })
   <div class="col-md-10">
       @Html.Editor("txtpickupdate", DateTime.Now.ToShortDateString(), new { htmlAttributes = new { @class = "form-control input-datepicker", @placeholder = "mm/dd/yyyy" } })  
       @Html.ValidationMessageFor(model => model.pickupdate_, "", new { @class = "text-danger" })
   </div>
</div>

 

 

Posted on Nov 25, 2016 02:34 AM

Hi GuruLogu,

There are options to set the default Date. If you didn't change anything by default it will show the current date. If you still want then you can set like below.

$( ".selector" ).datepicker({ defaultDate: new Date() });