End date must be equal and greater than start selected date in boostrap - datepicker

Requirements - End date must be equal and greater then start selected start date in boostrap datepicker and before selected start date disable.
Problem - its possible in jquery date but I want to know how to make in boostrap date.
my boostrap code is
$('#start_date').datepicker({autoclose: true,startDate: new Date()});
$('#end_date').datepicker({autoclose: true,startDate: new Date()});
for reference check jquery code
Fiddle
Note - I want exact implemention of this picker in bootstrap
Can anyone help me?

Please check out this JSFiddle demo. I have placed the code below that uses bootstrap datepicker.
$(".from_date").datepicker({
format: 'yyyy-mm-dd',
autoclose: true,
}).on('changeDate', function (selected) {
var startDate = new Date(selected.date.valueOf());
$('.to_date').datepicker('setStartDate', startDate);
}).on('clearDate', function (selected) {
$('.to_date').datepicker('setStartDate', null);
});
$(".to_date").datepicker({
format: 'yyyy-mm-dd',
autoclose: true,
}).on('changeDate', function (selected) {
var endDate = new Date(selected.date.valueOf());
$('.from_date').datepicker('setEndDate', endDate);
}).on('clearDate', function (selected) {
$('.from_date').datepicker('setEndDate', null);
});

Related

Flatpickr multiple datepicker in same page

I realize a site in symfony and I use the flatpickr library for the selection of dates. that's what it's like now:
datepicker
So I have 2 datepicker who uses flatpickr which allows me to select a departure date with the time and a date back with the time too. My problem, when I select the first date, flatpickr shows me well the time selection but when I go on the second datepicker I can not select the time.
datepicker 1
datepicker 2
I wish I could select in the 2 inputs the date and the time.
Here is my JS code of my 2 inputs:
var departure = $('#quick_booking_departure');
var arrival = $('#quick_booking_arrival');
departure.flatpickr({
enableTime: true,
dateFormat: "Y-m-d H:i",
position: "above",
disableMobile: true,
locale: "fr",
minDate: "today",
onChange: function (selectedDates, dateStr, instance) {
arrival.flatpickr({
minDate: dateStr
});
departure.removeAttr('readonly');
arrival.removeAttr('readonly');
}
});
arrival.flatpickr({
enableTime: true,
dateFormat: "Y-m-d H:i",
position: "above",
disableMobile: true,
locale: "fr",
minDate: "today",
onChange: function (selectedDates, dateStr, instance) {
departure.flatpickr({
minDate: 'today'
});
departure.removeAttr('readonly');
arrival.removeAttr('readonly');
}
});
Thank you for your help.
It looks like your onChange function is the culprit adding enableTime: true allows time pick:
onChange: function(selectedDates, dateStr, instance) {
arrival.flatpickr({
enableTime: true,
minDate: dateStr
});
departure.removeAttr('readonly');
arrival.removeAttr('readonly');
}
But look closer, when one of your pickers change you are completely re-initializing the other. So all the options you originally defined are getting reverted back to default except for what you are re-defining minDate

Date Picker in Ui5 allows to enter integers

I have a date picker in my XML view and it allowed to enter integer and even saved. How to validate if the user entered in right date format.
<DatePicker value="{model>Date}" valueFormat="yyyyMMdd"
displayFormat="dd/MMM/YYYY" change="Change"/>
Try this, THI.
Hope it helps.
onChange: function(oEvent) {
var bValid = oEvent.getParameter("valid");
var oDP = oEvent.getSource();
if (!bValid) {
sap.m.MessageToast.show("Entered date range isn't valid");
oDP.setValueState("Error");
return;
}
},

Disable Future Date in Datepicker of Materialize frame work

Here I am Using Date Picker of materialize frame work. Can anyone Please tell me how can i Disable Future Date from Current Date?
With 1.0 alpha version you can do you can specify maxDate in the options field when initializing the datepicker:
var elem = document.querySelector('.datepicker');
var instance = M.Datepicker.init(elem, {
maxDate: new Date()
});
// Or with jQuery
$(document).ready(function(){
$('.datepicker').datepicker({
maxDate: new Date(),
});
});
The other version v0.100.2 does not seem to have the maxDate option.
Please add this code to your script:
max: new Date()

Bootstrap Datepicker set Minimum Range

We are using Bootstrap Datepicker (https://github.com/uxsolutions/bootstrap-datepicker) to set a checkin and checkout date.
We need to be able to set a 'minimum range' on the date picker for properties that have a minimum night stay.
Missing Requirements:
Do not allow # of nights to be less than property nightly minimum.
Do not allow checkout date to be before checkin date.
So, if a visitor selects the checkin date of 12/01/2017, and the property has a minimum night stay of 3 nights, the visitor should not be allowed to select 12/02/2017, 12/03/2017. The next available night for them to checkout on should be 12/04/2017.
I'm not seeing that this is a simple option with this date picker. I do see that it has been added as a feature request by quite a few though.
https://github.com/uxsolutions/bootstrap-datepicker/issues/970
I've built the start of what might be able to work by using the disabledDates and setDatesDisabled dates. Yet, I can't seem to figure out why these disabledDates are not working or firing when selecting a new start date. I think that I should be able to combine the newly set disabled dates with those already posted.
$(function($) {
var today = new Date();
$('.input-daterange').datepicker({
daysOfWeekHighlighted: "0,6",
autoclose: true,
todayHighlight: true,
startDate: today,
datesDisabled: ['10/1/2017','10/2/2017','10/3/2017','10/4/2017','10/5/2017','10/6/2017','10/7/2017','10/8/2017','10/9/2017','10/10/2017','10/11/2017','10/12/2017','10/13/2017','10/14/2017','10/15/2017','10/16/2017','10/17/2017','10/18/2017','10/19/2017','10/20/2017','10/21/2017','10/22/2017','10/23/2017','10/24/2017','10/25/2017','10/26/2017','10/27/2017','10/28/2017','10/29/2017','10/30/2017','10/31/2017'],
});
});
// Set end date to minimum nights.
$('#start').on('change', function() {
// Set minNights.
minNights = 3;
start = $('#start').datepicker('getDate');
end = moment(start).add(minNights, 'day').toDate();
$('#end').datepicker('update', end);
$('.input-daterange').datepicker('setDatesDisabled', [ $('.input-daterange').datepicker('setDatesDisabled', ['12/02/2017', '12/03/2017']);]);
});
Is there another date picker that has this built in already? Or, is there a simple and clean way to add the missing requirements above to the bootstrap datepicker?
Simple JSFiddle
https://jsfiddle.net/riverecho/omd5uw21/
Give this a try
$(function () {
$('#datepicker').datepicker({
dateFormat: 'yy-mm-dd',
showButtonPanel: true,
changeMonth: true,
changeYear: true,
yearRange: '1999:2012',
showOn: "button",
buttonImage: "images/calendar.gif",
buttonImageOnly: true,
minDate: new Date(1999, 10 - 1, 25),
maxDate: '+30Y',
inline: true
});
});

adding bounce animation to date picker

I have a date picker using jquery. However I want to add the 'bounce' animation to it. Please help me adding this animation to the date picker. My code as of now is:
$(function() {
$("#datepicker").datepicker({ dateFormat: "DD, d MM, yy" });
});
Is this what you are trying to accomplish?
$(function() {
$("#datepicker").datepicker({ showAnim: "bounce", dateFormat: "DD, d MM, yy" });
});
http://jsfiddle.net/damyanpetev/VS2hV/
Additionally you can set duration and additional options that correspond to the effect you are using (in this case 'bounce' .