Frage

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%"})
            )
War es hilfreich?

Lösung

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'); 
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top