0

How to restrict a dates of datepicker Fuelux???

I have a datepicker with several properties . I need to restrict the first 20 days of January . Is it ( 01-01-2015 Up 20-01-2015 ).

$('#myDatepicker1').datepicker('setCulture', 'es');
$('#myDatepicker1').datepicker('setFormat', 'DD-MM-YYYY');
$('#myDatepicker1').datepicker('setDate', '01-22-2015');

I found the next code, but Dont worked.

$('#myDatepicker1').datepicker(
'setDate', '01-22-2015
restricted: [{from: '01-01-2013', to: '01-01-2014'}]');

In advance thanks for the help you can give me.

2 Answers2

0

setDate is not an initialization option. It is a method that can only be run once the control has been initialized.

Try something like this:

$('#myDatepicker1').datepicker({
    momentConfig: {
        culture: 'es',
        format: 'DD-MM-YYYY'
    },
    restricted: [{from: '01-01-2013', to: '01-01-2014'}]
});

$('#myDatepicker1').datepicker('setDate', '01-22-2015');

Be sure that you have the MomentJS library loaded before Fuel UX.

0

Excellent answer. Thank Interactive Llama. It worked and works perfect. He presented a problem because when you set the start date inside the range of blackout dates , the datepicker not understand this configuration and sets the current day.

The correct configuration is initialized by placing the date outside the range of time blackout dates .

I also tried loading the moment.js before and after fuelux file, and in both cases the datepicker worked. Anyway I preferred to leave it as you indicated. (Load moment.js file before the Fuelux library).

Here is the final code for its observation.

    $('#myDatepicker1').datepicker({
    allowPastDates: true,
    momentConfig: {
        culture: 'es',
        format: 'DD-MM-YYYY'
    },
    restricted: [
        {from: '01-01-1900', to: '31-12-2014'}
    ]
});
$('#myDatepicker1').datepicker('setDate', '01-01-2015');

Thanks for your help Interactive Llama.

  • momentJS support is optional, but recommended. Otherwise you will be relying on the browser's `parseDate()` which is inconsistent across browsers. – Interactive Llama Jun 26 '15 at 19:36