1

I have datepicker in my page. It work's fine. But my problem is that it shows '01/01/2001' as default date. It should shows '11/23/2012' now! My jquery code is:

        $(":input[data-datepicker]").datepicker();

What is problem with my code?

This is whole code of file:

$(document).ready(
function () {
    $(":input[data-autocomplete]").each(
        function () {
            $(this).autocomplete({ source: $(this).attr("data-autocomplete") });
        }
    );
    //$.datepicker.setDefaults($.datepicker.regional["en-GB"]);
    $(":input[data-datepicker]").datepicker({defaultDate: 0});

}
)

2 Answers 2

0

Here is a sample code...
It works fine by itself. Default date is 11/23/2012, also if you want you can move your default date to any date or explicitly define it like this: $(":input[data-datepicker]").datepicker({ defaultDate: 0 });.
Maybe you made some mistake using jQuery UI API, so your code broke?

EDIT: You can maybe try this: $("#datepick").datepicker({setDate: new Date()});

10
  • Unfortunately not works. I use jquery-ui-1.8.11.min.js API in MVC Web Application. Nov 23, 2012 at 20:45
  • The only explanation is that you have an error somewhere in your JS. Have you tried debugging it with Firebug or Chrome Developer tools?
    – ttkalec
    Nov 23, 2012 at 20:47
  • I didn't find any error in my code. I added whole file code to my question. Nov 23, 2012 at 21:13
  • I edited my answer with some code. You can try it. Also make sure that you are using the newest jQuery UI library.
    – ttkalec
    Nov 23, 2012 at 21:19
  • I tested with newest version, but it doesn't work! Unfortunately your edited code does not work! Nov 23, 2012 at 21:32
-1

You have to set the localization on the constuctor function.

See this page for more information.

2
  • Can you elaborate more in details? Nov 23, 2012 at 19:43
  • I don't think localization is the problem here.
    – ttkalec
    Nov 23, 2012 at 20:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.