jQuery UI datepicker 'setDate' method not working
NickName:Antonio Laguna Ask DateTime:2011-09-02T00:16:45

jQuery UI datepicker 'setDate' method not working

I'm having some issues with datepicker in jQuery.

I'm trying to put the today date in a field which is a datepicker.

I've tried with:

$('#fecha_alta').datepicker('setDate', new Date());
console.log($('#fecha_alta').datepicker('getDate'));

And

$('#fecha_alta').datepicker('setDate', '+0');
console.log($('#fecha_alta').datepicker('getDate'));

But always log null and also the input shows empty.

What's wrong?

Copyright Notice:Content Author:「Antonio Laguna」,Reproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/7273225/jquery-ui-datepicker-setdate-method-not-working

Answers
Arnaud Leymet 2011-09-01T17:22:11

If you need to set the date to the current one by default, then you may want to set it at start, when creating the widget:\n\n$('#datepicker').datepick({\n defaultDate: new Date()\n});\n",


Arnaud Leymet 2011-09-01T17:01:36

The following code works:\n\n$(document).ready(function() {\n $('#datepicker').datepicker('setDate', new Date());\n});\n\n\n(tested on the jQueryUI datepicker demo page)",


More about “jQuery UI datepicker 'setDate' method not working” related questions

datepicker jquery ui and moment datepicker

I'm using moment datepicker moment datepicker to display a calendar, I have also in my code, the jquery-ui js file, the calendar works fine until I add the jquery-ui file, the problem is that both

Show Detail

Jquery UI Datepicker not displaying

UPDATE I have reverted back to Jquery 1.3.2 and everything is working, not sure what the problem is/was as I have not changed anything else apart of the jquery and ui library versions. UPDATE END I

Show Detail

Jquery UI:datepicker

I'm using Jquery UI datepicker in one of my projects. I need to disable US holiday dates. I tried jQuery UI Datepicker - Disable specific days and Can the jQuery UI Datepicker be made to disable

Show Detail

jQuery ui datepicker conflict with bootstrap datepicker

I want to show two months using bootstrap datepicker. After search on google I am not able to find how to show multiple months using bootstrap datepicker. I found that I can use JQuery UI for displ...

Show Detail

jQuery ui datepicker conflict with bootstrap datepicker

I want to show two months using bootstrap datepicker. After search on google I am not able to find how to show multiple months using bootstrap datepicker. I found that I can use JQuery UI for displ...

Show Detail

Jquery datepicker UI

Hi I am struggling to get this Date/Calendar Jquery UI to work in Angularjs (as a beginner). The UI widget is not appearing and the error message I am getting is: TypeError: elem.datepicker is not a

Show Detail

jquery UI: Datepicker does not appear

For some unknown reasons DAta Picker is not appearing on the Browser. I cam calling an HTML file via Ajax which itself has a document.ready() function. On clicking the date field, it does generate ...

Show Detail

jQuery UI DatePicker: no CSS, no selection

I am trying to get a jQuery UI DatePicker working. I uploaded the contents of the development-bundle folder to the folder res/jqueryui and set up two datepickers like so: <script src="res/jquer...

Show Detail

Datepicker jquery ui-datepicker-trigger

I need to add two calendar jQuery objects to the html page. I have the below setting for date picker. Have an icon image for opening the calendar object. For absolute positioning the icon image do...

Show Detail

Extending jQuery UI datepicker

I'm trying to extend jQuery's datepicker via the $.widget function, jQuery UI 1.10.3, with $.ui.datepicker as the base. It seems that $.ui.datepicker is an object (unlike pretty much all the other

Show Detail