ComboBox with numeric values

1 Answer 84 Views
ComboBox
Bernd
Top achievements
Rank 5
Bronze
Bronze
Bronze
Bernd asked on 11 Mar 2022, 10:10 AM

I'm using a comboBox with the allowCustom setting. 2 questions:

1) How can I make sure that only integer values can be entered as custom value (meaning numeric values without decimal point)?

2) How can I make sure that only double values can be entered as custom value (meaning numeric values with or without decimal point)?

 

1 Answer, 1 is accepted

Sort by
1
Accepted
Konstantin Dikov
Telerik team
answered on 14 Mar 2022, 12:11 PM

Hi Bernd,

The KendoReact Combobox component provides "onChange" event that can be used for manipulating the custom value, but it will fire only when the user blur the input (select the value). Within the event you can perform validation and do not change the state value if it does not match your requirement.

Another option would be to attach event handler for the keydown event of the input element and allow only numeric values, the decimal separator and the delete key. I have created a simple example with this approach, but you can modify it as per the exact requirements:

Hope this helps.

 

Regards,
Konstantin Dikov
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Bernd
Top achievements
Rank 5
Bronze
Bronze
Bronze
commented on 14 Mar 2022, 04:04 PM

Awesome! Exactly what I was looking for! THANKS!
Tags
ComboBox
Asked by
Bernd
Top achievements
Rank 5
Bronze
Bronze
Bronze
Answers by
Konstantin Dikov
Telerik team
Share this question
or