Date Range Validation
- WinstonFroidPinto
- Posts: 32
- Joined: Thu Mar 16, 2017
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.
Thanks.
- Dmitry Kozlov
- Site Admin
- Posts: 1524
- Joined: Thu Jun 07, 2012
Hi,
Please, insert the following code into JS-editor:
Replace 'FromDate' and 'ToDate' with the internal names of the corresponding fields. If you use Date Only fields, replace 'kendoDateTimePicker' with 'kendoDatePicker'.
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);
- WinstonFroidPinto
- Posts: 32
- Joined: Thu Mar 16, 2017
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)
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)
- WinstonFroidPinto
- Posts: 32
- Joined: Thu Mar 16, 2017
Also would like to know how to change the interval in kendo datetimepicker to 15min?
Thanks.
Thanks.
- Dmitry Kozlov
- Site Admin
- Posts: 1524
- Joined: Thu Jun 07, 2012
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()
min: fd.field('FromDate').value()
So, this method returned null:
fd.field('FromDate').value()
-
- Information
-
Who is online
Users browsing this forum: No registered users and 18 guests