I'm using the Kendo UI Numeric Textbox. I have a max value set on the text box. However, I want the max value to work more like max-char attribute.
Currently, if I type in anything past 99999, say 111111, it reverts to max value (99999), I would rather the textbox just prevent additional numbers than to revert to 9999.
@(Html.Kendo().NumericTextBox<double>()
.Name("XXXX")
.Max(99999)
.Min(1)
.Format("\\#")
.HtmlAttributes(new { style="width:100%"})
)
Use the maxLength attribute of the input. So, on page load, do the following:
$("#XXXX").attr('maxlength','5');
Edit based on comments : In order to apply rule to all numeric boxes, the following should work:
$("input[data-role='numerictextbox']").attr('maxlength','5');
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With