Search code examples
razorkendo-uikendo-asp.net-mvc

How to disable decimals in Kendo NumericTextBox


<kendo-numerictextbox id="example1" name="example1" value="@Model.Example1" min="0" format="n0"  decimals="0" data-bind="value: Example1" class="form-control" disabled="@isDisabled" placeholder="0" auto-bind="true"></kendo-numerictextbox>

I don't want any decimals for the above input. I have tried several methods to restrict decimals but sadly nothing is working.

Tried the following things:

  1. format="n0"
  2. decimals="0"
  3. restrictDecimals="true"

But, still user is able to enter decimal and values after it.


Solution

  • In the above example the restrict-decimals attribute is missing. Also multi word attributes are normally added in kebab-case, rather than camelCase. So adding the restrict-decimals attribute will essentially restrict the decimals.