10 examples of 'how to set min date in datepicker using javascript' in JavaScript

Every line of 'how to set min date in datepicker using javascript' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your JavaScript code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
this disclaimer
32get min(): Date {
33 const date: Date = new Date();
34 return new Date(date.getFullYear(), date.getMonth(), 1);
35}
Important

Use secure code every time

Secure your code as it's written. Use Snyk Code to scan source code in minutes – no build needed – and fix issues immediately. Enable Snyk Code

86export function minDateToDateRangePicker(model: any, formState: any, field) {
87 let date = null;
88 //Setting a minumn date for the date range picker
89 if (field.parent.templateOptions.minDate) {
90 date = new Date(field.parent.templateOptions.minDate.getTime());
91 }
92 if (model) {
93 if (model.fromDate) {
94 date = model.fromDate;
95 }
96 }
97
98 return date;
99 }
106public setMinimumDate(calendarMinDate: Date): void {
107 this._minimumDate = calendarMinDate;
108}
60function setDatePicker(){
61 var dates = $( "#f1, #f2" ).datepicker({
62 changeMonth: true,
63 changeYear: true,
64 numberOfMonths: 1,
65 dateFormat: "dd.mm.yy",
66 minDate: "01.01."+times[currentLevel+1][firstBar][1],
67 maxDate: "31.12."+times[currentLevel+1][lastBar][1],
68 //beforeShow: function(input, inst) {
69 // $("#ui-datepicker-div").css("z-index", 100);
70 //},
71 onSelect: function( selectedDate ) {
72 var option = this.id == "f1" ? "minDate" : "maxDate",
73 instance = $( this ).data( "datepicker" ),
74 date = $.datepicker.parseDate(
75 instance.settings.dateFormat ||
76 $.datepicker._defaults.dateFormat,
77 selectedDate, instance.settings );
78 dates.not( this ).datepicker( "option", option, date );
79 }
80 });
81 $('#ui-datepicker-div').hide();
82}
18function updateDatePicker() {
19
20 var startMonth = new Date();
21
22 $("#dpStart").datepicker("option", "dateFormat", "yy-mm-dd");
23 $("#dpStart").datepicker("setDate", startMonth);
24}
77function getMinDate() {
78 return new Date($.datepicker.formatDate(startEndDateFormat, startDate));
79}
178getMinYear() {
179 return this.getMinDate().getFullYear();
180}
83_getDate(date, minDate = this.state.minDate, maxDate = this.state.maxDate) {
84 // If no date is provided then use current date
85 // Make sure we constrain it to the min and max
86 const current = (date instanceof Date) ? date : new Date();
87
88 if (minDate && current < minDate) {
89 return minDate;
90 }
91
92 if (maxDate && current > maxDate) {
93 return maxDate;
94 }
95
96 return current;
97}
75function setupDatepickers() {
76 var numRows = parseInt($('#numRows').val());
77 for (var idx = 0; idx < numRows; ++idx) {
78 $('#date' + idx).datepicker();
79 }
80}
129export function setMinDate(date: Date) {
130 if (_isInitFunction()) {
131 mPickerManager.minimumDate = _toNativeDate(date);
132 }
133}

Related snippets