I have a text field.
<input type="number" min="0" max="999">
But i am able to type as many numbers inside the text box.
As I set max=999, I don't want that to happen.
Anyone knows the solution for this?
I have tried ng-maxlength
and maxlength
but doesn't work.
The <input> maxlength attribute is used to specify the maximum number of characters enters into the <input> element. Attribute Value: number: It contains single value number which allows the maximum number of character in <input> element. Its default value is 524288.
The <input type="range"> defines a control for entering a number whose exact value is not important (like a slider control). Default range is 0 to 100. However, you can set restrictions on what numbers are accepted with the attributes below. Tip: Always add the <label> tag for best accessibility practices!
The maxlength attribute specifies the maximum number of characters allowed in the <input> element.
max
attribue specifies the maximum possible value that we can specify.
for more details see this link
I think the following will be helpful to you,
//maxlength="10"
<input type="number" onKeyPress="if(this.value.length==10) return false;" />
Try
<input type="number" min="0" max="999"
onKeyUp="if(this.value>999){this.value='999';}else if(this.value<0){this.value='0';}"
id="yourid">
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