Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jquery datepicker not assigning date

Tags:

jquery

I have a text box with an id of InactiveDate. It has a datepicker attached to it,

I tried the following but wasn't able to successfully populate the date: (Note I hardcoded for testing)

$('#InactiveDate').datepicker('09/09/2012');

Although my control is called InactiveDate, looks like below it make is hidden so not sure what to try.

When I run above code no date gets populated.

Here is what it looks like:

    <div id="datePicker_InactiveDate">
    <script language="javascript" type="text/javascript">
    <input id="InactiveDate" class="data" type="hidden" value="" name="InactiveDate">
    <input id="dp1342109969094" class="date hasDatepicker" type="text"     onchange="javascript:updateData_InactiveDate()" value="">
    </div>
    <span class="field-validation-valid" data-valmsg-replace="true" data-valmsg-for="InactiveDate"></span>
    </div>
like image 731
Nate Pet Avatar asked Apr 18 '26 20:04

Nate Pet


1 Answers

That's not how .datepicker works. You need to use the setDate method.

$('#InactiveDate').datepicker('setDate', '09/09/2012');

Docs: http://jqueryui.com/demos/datepicker (Click the "methods" tab)

like image 104
Rocket Hazmat Avatar answered May 05 '26 10:05

Rocket Hazmat