Set the min date on the kendoMaskedDatePicker - javascript

I am using the kendo masked date picker (Kendo.MaskedDatePicker.js) and I can't find anything that shows how to set the minimum date.
$('#StartDate, #EndDate').kendoMaskedDatePicker({
dateOptions: {
mask: '00/00/0000',
format: 'MM/dd/yyyy',
min: new Date(2017, 11, 1)
}
}).parent().parent().removeClass('k-header');
This doesn't seem to work.

$('#StartDate, #EndDate').kendoMaskedDatePicker({
min:new Date(2017, 11, 01),
parseFormats: ["MM/dd/yyyy"],
dateOptions: {
mask: '00/00/0000',
format: 'MM/dd/yyyy',
}
}).parent().parent().removeClass('k-header');
Dojo here

Related

Pikaday i18n still showing names of the days and months in english

I'm using pikaday with the i18n option with names of the months and days in spanish, my problem is that in the input text/placeholder still shows the english names of said months.
This is my JS code:
var picker = new Pikaday(
{
numberOfMonths: 2,
field: document.getElementById('datepicker-2months'),
firstDay: 1,
minDate: new Date(2000, 0, 1),
maxDate: new Date(2020, 12, 31),
yearRange: [2000, 2020],
i18n: {
previousMonth : 'Mes anterior',
nextMonth : 'Mes siguiente',
months : ['Enero','Febrero','Marzo','Abril','Mayo','Junio','Julio','Agosto','Septiembre','Octubre','Noviembre','Diciembre'],
weekdays : ['Domingo','Lunes','Martes','Miercoles','Jueves','Viernes','Sabado'],
weekdaysShort : ['Dom','Lun','Mar','Mier','Jue','Vie','Sab']
}
});
This should be straight forward but i'm puzzled as the pop-up calendar shows the names in the correct language, but not in the input placeholder.
Your code should work fine.Check for other dependencies which may cause the issue.
Check below:
var picker = new Pikaday(
{
numberOfMonths: 2,
field: document.getElementById('datepicker-2months'),
firstDay: 1,
minDate: new Date(2000, 0, 1),
maxDate: new Date(2020, 12, 31),
yearRange: [2000, 2020],
i18n: {
previousMonth : 'Mes anterior',
nextMonth : 'Mes siguiente',
months : ['Enero','Febrero','Marzo','Abril','Mayo','Junio','Julio','Agosto','Septiembre','Octubre','Noviembre','Diciembre'],
weekdays : ['Domingo','Lunes','Martes','Miercoles','Jueves','Viernes','Sabado'],
weekdaysShort : ['Dom','Lun','Mar','Mier','Jue','Vie','Sab']
}
});
<link rel="stylesheet" href="https://dbushell.com/Pikaday/css/pikaday.css">
<script src="https://dbushell.com/Pikaday/pikaday.js"></script>
<br><br><br><br><br><br><br><br><br><br><br>
<label for="datepicker-2months">Date:</label>
<input type="text" id="datepicker-2months">
The Pikaday i18n normally uses moment.js. If you don't want to use that, you have to do it yourself. You already provide the month and day names… but not the method that is used to fill in the input box value. This is done with the toString() method:
var monthNames = ['Enero', 'Febrero', 'Marzo', 'Abril', 'Mayo', 'Junio', 'Julio', 'Agosto', 'Septiembre', 'Octubre', 'Noviembre', 'Diciembre'],
picker = new Pikaday({
numberOfMonths: 2,
field: document.getElementById('datepicker-2months'),
firstDay: 1,
minDate: new Date(2000, 0, 1),
maxDate: new Date(2020, 12, 31),
yearRange: [2000, 2020],
i18n: {
previousMonth: 'Mes anterior',
nextMonth : 'Mes siguiente',
months : monthNames,
weekdays : ['Domingo', 'Lunes', 'Martes', 'Miercoles', 'Jueves', 'Viernes', 'Sabado'],
weekdaysShort: ['Dom', 'Lun', 'Mar', 'Mier', 'Jue', 'Vie', 'Sab']
},
toString: function(date) {
var parts = [date.getDate(), monthNames[date.getMonth()], date.getFullYear()];
return parts.join(" ");
}
});
Try it on Codepen
If you want to be able to parse text from the input box to get the correct value in the calendar, you'll also need to implement the parse() method… but at this point it may be easier to use moment.js and let it handle the i18n for you.
This is all described in the Formatting section of the Pikaday doc.
To achieve expected result , use below option
Import Locale/es.js and Set Locale to spanish using moment - moment.locale('es') ;
In locale section of Pikaday, use moment for months , weekdays and weekdaysShort instead of providing hard coded values
<input type="text" id="datepicker-2months" value="9 Octubre 2014">
<link rel="stylesheet" href="https://dbushell.com/Pikaday/css/pikaday.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.22.2/moment.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/pikaday/1.6.1/pikaday.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.22.2/locale/es.js"></script>
<script>
//Set Locale to spanish
moment.locale('es');
var picker = new Pikaday(
{
numberOfMonths: 2,
field: document.getElementById('datepicker-2months'),
firstDay: 1,
minDate: new Date(2000, 0, 1),
maxDate: new Date(2020, 12, 31),
yearRange: [2000, 2020],
format: 'D MMM YYYY',
i18n: {
previousMonth : 'Mes anterior',
nextMonth : 'Mes siguiente',
months : moment.localeData()._months,
weekdays : moment.localeData()._weekdays,
weekdaysShort : moment.localeData()._weekdaysShort
}
});
</script>
codepen for reference

foundation datepicker datesdisabled

I am trying to disable holidays in my calendar but can't seem to pass the right format to the datesdisabled option.
I have
$('#booking').fdatepicker({
var now = new Date();
$('#booking').fdatepicker({
format: 'dd MM yyyy',
startDate: now,
daysOfWeekDisabled: [0, 4, 5],
datesDisabled:['2018-02-13']
});
})
What am I missing?
Use it this way, as it doesn't support the way you are using it. Also, it doesn't support time, just date.
$(function(){
$('#dpt').fdatepicker({
initialDate: new Date(),
format: 'yyyy-mm-dd hh:ii',
disableDblClickSelection: true,
language: 'es',
pickTime: true,
datesDisabled:['2018-01-15']
});
});

How to disable date before today in datetimepicker bootstrap?

Demo and full code is like this : http://fiddle.jshell.net/oscar11/dgb09c5c/5/
My Javascript code is like this :
$('#time-start').datetimepicker({
format: 'yyyy-mm-dd hh:ii:ss',
autoclose: true,
pickerPosition: "bottom-left",
maxView: 3,
minuteStep: 1,
minDate: new Date()
})
How to disable date before today?
I add minDate: new Date(), but it's not working
Any solution to solve my problem?
From Bootstrap datetime picker documentation
$.fn.datetimepicker.defaults = {
maskInput: true, // disables the text input mask
pickDate: true, // disables the date picker
pickTime: true, // disables de time picker
pick12HourFormat: false, // enables the 12-hour format time picker
pickSeconds: true, // disables seconds in the time picker
startDate: -Infinity, // set a minimum date
endDate: Infinity // set a maximum date
};
I modified your Fiddle. Is it what you are looking for? http://fiddle.jshell.net/dgb09c5c/6/

Completely disabling dates out of the given range

I was using this plugin https://github.com/dangrossman/bootstrap-daterangepicker/ for a daterange picker. I want to completely disable/hide the dates that are out of the given start and end date range. Can some one help me with this please.
$('#datrange').daterangepicker({
timePicker: true,
timePickerIncrement: 30,
format: 'MM/DD/YYYY h:mm A',
startDate: moment().subtract('days', 29),
endDate: moment()
});
This is the code I use now.
Taking a look at the documentation on the page you linked, I'd say you need these options:
minDate: (Date object, moment object or string) The earliest date a user may select
maxDate: (Date object, moment object or string) The latest date a user may select
Which probably work something like this:
$('#datrange').daterangepicker({
timePicker: true,
timePickerIncrement: 30,
format: 'MM/DD/YYYY h:mm A',
startDate: moment().subtract('days', 29),
endDate: moment(),
minDate: moment().subtract('days', 100),
maxDate: moment().add('days', 100) // Using moment objects as a example.
});

initialDate not working in bootstrap-datetimepicker?

My today Date is 16-1-2014 and I set default date is 17-01-2014 but this is not working
$('#datetimepicker').datetimepicker({
startDate: new Date(),
autoclose: true,
todayBtn: true,
todayHighlight: false,
initialDate: new Date(2014, 00, 17),
//update: new Date(2014, 00, 17),
// onRender: function(ev) {
// console.log(ev.date.valueOf());
// },
format: 'dd/MM/yyyy hh:mm:ss',
language: 'en'
})
output show on calendar
I am using below library
bootstrap-datetimepicker
Looking at the code it looks like the initialDate is not considered at all if your input element has a value attribute.
So if you want initiaDate to be used, make sure your input doesn't have a value (i.e. value="" or no value at all).

Categories