Bootstrap datepicker, disable dates - view only mode possible? - javascript

I'm loading a selection of dates into bootstrap datepicker for the user to view. Currently they can click on a highlighted date but it clears all the dates that are preloaded.
I don't want them to be able to click on any dates, just view the different month pages of dates. How can I do this?
this is how I setup datepicker and load the dates;
$('.datepickera').datepicker({
format: 'yyyy/mm/dd',
multidate: false
});
$.extend($.datepicker,{_checkOffset:function(inst,offset,isFixed){return offset}});
$(".datepickera").data("datepicker").setDates($('#mydates').data('dates'));

If I understand you correctly you can make the datepicker unselectable by using the daysOfWeekDisable property like this:
$('.datepicker').datepicker({
daysOfWeekDisabled: [0,1,2,3,4,5,6]
});
0 is Sunday and 6 is Saturday. This way a user cannot select any day but can view the entire calendar. You can read more about it here. Hope that helps.

Related

bootstrap 3 datetimepicker custom year

I need a calendar popup for my project and I just want to show years just like this. (2000 - 2009)
I found this library Bootstrap 3 Datepicker and it seems easy. Then I've configured it to show years. Worked fine.
But I want to show 2000-2009 range in dropdown. That's the problem. I used "viewMode" option to show years. But I couldn't find anywhere to show custom year range. Here is my js code. And here is jsfiddle for live example. Any solution?
$(function () {
$('#datetimepicker10').datetimepicker({
viewMode: 'years',
format: 'L'
});
});
$('#datetimepicker10').datetimepicker({
viewMode: 'years',
defaultDate : '2005-01-01',
format: 'L'
});
set
defaultDate : '2005-01-01'
jsfiddle

Angular UI Bootstrap Datepicker - show specific date on Calendar open

I am using Angular UI Bootstrap dirrective for Datepicker. I have list of dates, that I set in calendar as active (i.e. other dates are disabled).
Here is my date list - ["10/16/2015", "11/20/2015", "12/18/2015"]
UI Datepicker always open current date/month. How can I make, so calendar would open on specific date, even if this date is from previous year?
I found option defaultViewDate option, but it seems that it doesn't work (at least I didn't find this method in tpl library)
Any ideas how I can make that?
Thanks!
Given Angular UI's documentation on its datepicker, the calendar adapts to a date set on the ng-model, so all you'd have to do is create a date:
new Date(year, month, day, hours, minutes, seconds, milliseconds);
See w3schools for more on that.
Set the model to that and you should be good to go. Let us know if it works.
EDIT:
To set the initial date when no date is specified, use init-date by creating a default date on the scope of the parent controller.
angular.module("yourModule").controller("parentCtrl", function($scope) {
$scope.initialDate = new Date(2000, 5, 4);
}
And the HTML:
<div ng-controller="parentCtrl">
<datepicker init-date="initialDate"></datepicker>
</div>
Hope it helps.

Bootstrap Datepicker maximum selection of N days

I've got datepicker with option multidate and I want to define maximum days which user can select, for example 5 days, other days should be disabled. It should happen dynamically - user can select arbitrary 5 days and then other days should be blocked. How can I do that ?
Based on the documentation for the bootstrap-datepicker plugin you are using, it looks like if you just do multidate: 5 "the picker will limit how many dates can be selected to that number, dropping the oldest dates from the list when the number is exceeded."
$('#datepicker').datepicker({
multidate: 5
});
As for disabling the days once 5 are selected, rather than dropping the oldest...I am not sure if that is possible. You might be able to do something like this (but not sure, as you would have to pass in a big array of dates):
$('#datepicker').datepicker({
multidate: 5
}).on('changeDate', function(e){
//some function here to disable dates once 5 are selected
});
Hope this helps.

Customize the jquery Datepicker

i am using jqueryDate picker.i want to customize this Datepicker.In this Datepicker Month and year is showing.Like August2014.Here if i click next it will go to next month like previous.
But I want to customize,mean i want to show months in dropdown and Year also i have to show in Dropdown,amd Next and previous function should be work.Can You Please suggest Me.
What plugin are you trying to use. If it is this plugin found in this site. then all you need to do is set the change month and changeyear to true.
$(function() {
$("YOURSELECTOR" ).datepicker({
changeMonth: true,
changeYear: true
});
});
the documentation for the api can be found here.

How to display hours in JQuery datapicker

I want to use simple JQuery datapicker but not only to select the date. I want to add hours to the date format but I also want to preserver the classic vie of the calendar. I just want to add hours as extra functionality to define precisely the time. Is this possible?
<script type="text/javascript">
//For calendar
$(".datepicker").datepicker({
inline: true,
showWeek: true,
firstDay: 1,
dateFormat: 'yyyy-mm-dd HH:MM:ss',
});
</script>
http://trentrichardson.com/examples/timepicker/
you can try the above plugin with the combination of datepicker
you can even use the default $('.datepicker').datetimepicker();
jQuery UI's datepicker picks dates, not times. You can add a distinct field for the hours, e.g. a select field.

Categories

Resources