Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Kendo UI Numeric Textbox - Max Value

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%"})
            )
like image 568
Mark Avatar asked May 25 '26 01:05

Mark


1 Answers

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'); 
like image 71
thispatchofsky Avatar answered May 27 '26 13:05

thispatchofsky



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!