dubrox / Multiple-Dates-Picker-for-jQuery-UI

MDP is a little plugin that enables jQuery UI calendar to manage multiple dates.
https://dubrox.github.io/Multiple-Dates-Picker-for-jQuery-UI
273 stars 159 forks source link

dateFormat -> Uncaught Unexpected literal at position 2 #41

Closed poldixd closed 10 years ago

poldixd commented 12 years ago

Hello,

if i set the dateFormat to the german format 'dd.mm.yy' and the mode to 'daysRange', the following Exception were thrown by the console:

Uncaught Unexpected literal at position 2 jquery-ui.js:8230
checkLiteral jquery-ui.js:8230
$.extend.parseDate jquery-ui.js:8279
methods.dateConvert jquery-ui.multidatespicker.js:239
dateConvert jquery-ui.multidatespicker.js:64
methods.sumDays jquery-ui.multidatespicker.js:200
methods.toggleDate jquery-ui.multidatespicker.js:366
(anonymous function) jquery-ui.multidatespicker.js:435
jQuery.extend.each jquery.js:611
jQuery.fn.jQuery.each jquery.js:241
$.fn.multiDatesPicker jquery-ui.multidatespicker.js:422
mdp_events.onSelect jquery-ui.multidatespicker.js:82
$.extend._selectDate jquery-ui.js:8111
$.extend._selectDay jquery-ui.js:8090
handler.selectDay jquery-ui.js:8614
jQuery.event.dispatch jquery.js:3063
elemData.handle.eventHandle jquery.js:2681

Here is the code:

    <script>

        $(function() {
            $('#result').multiDatesPicker({
                mode: 'daysRange',
                dateFormat: 'dd.mm.yy',
                minDate: new Date(2012, 12, 24),
                maxDate: new Date(2012, 12, 30),
                autoselectRange: [0,3]
            });
        });
    </script>   

  </head>
  <body>
    <div id="result"></div>
  </body>

is this a bug from the jquery-ui.multidatespicker.js or the jquer ui?

I need the german format!

greetings from Berlin!

ghost commented 11 years ago

From what I can tell, this seems to be an issue with jquery ui. What version are you using?

AlexL commented 10 years ago

I had the same issue. You need to match the value of 'dateFormat' with the dates you provide to the picker at instantiation. In your case, the minDate and maxDate need to be strings in 'dd.mm.yy' format

iarovyi commented 9 years ago

I have the same issue and I have no minDate or maxDate and I follow to my format when I set initial value. Version is "jQuery UI - v1.10.4 - 2014-01-17".

Html: <input class="text-box single-line hasDatepicker" data-val="true" data-val-date="The field Target Close Date must be a date." id="Issue_CloseDate" name="Issue.CloseDate" type="text" value="31/05/2015">

datepicker dafaults: $.datepicker.setDefaults({ dateFormat: 'dd/mm/yy' });

EXCEPTION: when I call next method $.datepicker.parseDate('dd/mm/yy', "999/05/2015"); then it raises the following exception: "Uncaught Unexpected literal at position 2"

charlesmudy commented 9 years ago

Any recommended solution on this issue?

RyuJun commented 8 years ago

your code.

    $(function() {
        $('#result').multiDatesPicker({
            mode: 'daysRange',
            dateFormat: 'dd.mm.yy',
            minDate: new Date(2012, 12, 24),
            maxDate: new Date(2012, 12, 30),
            autoselectRange: [0,3]
        });
    });

-------------------------modify code-----------

    $(function() {
        $('#result').multiDatesPicker({
            mode: 'daysRange',
            dateFormat: 'yy.mm.dd', 
            // min or max Date Formet == yy.mm.dd       
            // your dateFormat [dd.mm.yy] ---> [yy.mm.dd]  modify 

            minDate: new Date(2012, 12, 24),
            maxDate: new Date(2012, 12, 30),
            autoselectRange: [0,3]
        });
    });