Page 1 of 1

Date Range Validation

Posted: 16 Mar 2017
by WinstonFroidPinto
I have two dependent( from date and to date) datetime fields(using kendodatetimepicker template) in my form.How can we only show to date which is greater than the from date and disable dates which are less than from date on selection of from date?

Thanks.

Re: Date Range Validation

Posted: 17 Mar 2017
by Dmitry Kozlov
Hi,

Please, insert the following code into JS-editor:

Code: Select all

function setToDateRange() {
	fd.field('ToDate').control('kendoDateTimePicker')
		.done(function(picker) {
			picker.setOptions({
			    min: fd.field('FromDate').value()
			});
		});
}

fd.field('FromDate').change(setToDateRange);
Replace 'FromDate' and 'ToDate' with the internal names of the corresponding fields. If you use Date Only fields, replace 'kendoDateTimePicker' with 'kendoDatePicker'.

Re: Date Range Validation

Posted: 19 Mar 2017
by WinstonFroidPinto
Thanks for the reply Dmitry.

I have copied the above code in js editor,getting the below error on change of from date in console

Uncaught TypeError: Cannot read property 'getHours' of null
at o (plumsail.fd.kendo.js:11)
at init._calculateMidnight (plumsail.fd.kendo.js:11)
at init.setOptions (plumsail.fd.kendo.js:11)
at fd_Item_05abedc5-dbf8-4bbf-8cfc-b5559d7cac0e_New.aspx?List=e0677224-8267-4170-9b42-503ac03750e7&Lis…:689
at j (plumsail.fd.jquery.js?rev=uWqMkVfr%2B6VHuu0VYpVNCg%3D%3DTAG0:2)
at Object.add [as done] (plumsail.fd.jquery.js?rev=uWqMkVfr%2B6VHuu0VYpVNCg%3D%3DTAG0:2)
at HTMLInputElement.setToDateRange (fd_Item_05abedc5-dbf8-4bbf-8cfc-b5559d7cac0e_New.aspx?List=e0677224-8267-4170-9b42-503ac03750e7&Lis…:688)
at HTMLInputElement.dispatch (plumsail.fd.jquery.js?rev=uWqMkVfr%2B6VHuu0VYpVNCg%3D%3DTAG0:4)
at HTMLInputElement.r.handle (plumsail.fd.jquery.js?rev=uWqMkVfr%2B6VHuu0VYpVNCg%3D%3DTAG0:4)
at Object.trigger (plumsail.fd.jquery.js?rev=uWqMkVfr%2B6VHuu0VYpVNCg%3D%3DTAG0:4)

Re: Date Range Validation

Posted: 19 Mar 2017
by WinstonFroidPinto
Also would like to know how to change the interval in kendo datetimepicker to 15min?

Thanks.

Re: Date Range Validation

Posted: 20 Mar 2017
by Dmitry Kozlov
Most likely, you did not put the correct internal name in this line of the snippet:
min: fd.field('FromDate').value()

So, this method returned null:
fd.field('FromDate').value()