Disable Future Date in Datepicker of Materialize frame work - datepicker

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()

Related

Set default date on Datepicker (SAP UI5)

I want to set default date to a date that I pick NOT a current date even you refresh page. Does anyone know how to fix its?
this.getView().getModel("navModel").setProperty("/targetRouteParams", {
view: "Overview",
date: moment().format("YYYY-MM-DD")
Please follow below steps as one of the approaches. You can set one property with default date in your JSON model.
Controller
onInit : function () {
var oModel = new JSONModel({
dDefaultDate : new Date()
});
this.getView().setModel(oModel, "view");
}
View
<DatePicker
id="idDatePicker"
value="{
path: 'view>/dDefaultDate',
type: 'sap.ui.model.type.Date'
}"
valueFormat="yyyy-MM-dd"
displayFormat="long" />

MinDate and MaxDate are not working for the native date picker in Ionic 4

I am working in my Ionic 4 project and I have used the native date picker plugin. It is working fine but I am not able to set the min and max date in it for the Android.
This is my tab2.page.html:
<ion-input formControlName="startchallenge" placeholder="Select Date" (click)="datePickershow()" [readonly]=true></ion-input>
This is my tab2.page.ts:
datePickershow(){
this.datePicker.show({
date: new Date(),
mode: 'date',
androidTheme: this.datePicker.ANDROID_THEMES.THEME_HOLO_DARK,
minDate: new Date().toISOString(),
maxDate: new Date(new Date().setDate(new Date().getDate() + 10)).toISOString(),
}).then(
date => console.log('Got date: ', date)},
err => {
console.log('Error occurred while getting date: ', err)}
);
}
I have used min and max date in Android after that the user is able to select the back date from today because I have used the min date as a today date but the problem is that user is able to select the previous date in Android.
Any help is much appreciated.
Try This:
minDate: new Date().valueOf(),
maxDate: new Date(new Date().setDate(new Date().getDate() + 10)).valueOf(),
This will solve your problem.
I think you should use ion-datetime, which provide easiest way to getting date or time from user.
There are lots of methods to formate date and time input.

SAPUI5 DatePicker / DateRangePicker. Min + Max dates

I can set the dateValue attribute in the Date Pickers, but unfortunately the user can still enter a date before it.
Is there any way I can set an minimum (and maximum) date on the datepicker?
Regards
Adam
Unfortunately until the current Version 1.36 of SAPUI5 the control sap.ui.commons.DatePicker does not provide such functionalities. But you still can handle this yourself with the change event.
var minDate = "12121991";
var maxDate = "12122020";
var oDatePicker = new sap.ui.commons.DatePicker();
oDatePicker .attachChange(function(oEvent) {
if(oEvent.getParameter("invalidValue") || this.getYyyymmdd() < minDate || this.getYyyymmdd() > maxDate) {
oEvent.oSource.setValueState(sap.ui.core.ValueState.Error);
} else{
oEvent.oSource.setValueState(sap.ui.core.ValueState.None);
}
});

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

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);
});

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' .