Setting selectable date for date picker

1 Answer 95 Views
Date/Time Pickers DateInput NumericTextBox
Benjamin
Top achievements
Rank 2
Iron
Iron
Veteran
Benjamin asked on 16 Dec 2022, 06:01 AM

I have 2 fields in my form. 

the first field is using NumericTextBox to set a year

the 2nd field would be a date picker with date input to select the date, the format would be dd MM

I would like to check if it is possible, onblur of the numeric textbox would set the date-picker selectable dates based on the year entered in the first field

1 Answer, 1 is accepted

Sort by
0
Lyuboslav
Telerik team
answered on 19 Dec 2022, 02:30 PM

Hi Benjamin,

Firstly, you need to use the "editorOptions" property of the  Form and configure the NumericTextBox widget. After that, you should handle the "change" event. This event helps when setting the value and the widget is onblur:

editorOptions:{
              	change:(e)=>{
                  var textBox = e.sender;
                  var datePicker = $("#DatePicker").data("kendoDatePicker");
                  var value = textBox.value();
                  datePicker.min(`${value}-01-01`);
                  datePicker.max(`${value}-12-31`);
                }
              }

Finally, as you can see above, to select days and months from the year in the NumericTextBox you should use the "min" and "max" methods from the DatePicker component.

I prepared a sample dojo example with the example above.

I hope this will help you.

Regards,
Lyuboslav
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Tags
Date/Time Pickers DateInput NumericTextBox
Asked by
Benjamin
Top achievements
Rank 2
Iron
Iron
Veteran
Answers by
Lyuboslav
Telerik team
Share this question
or