E
E
Erl2020-05-24 08:28:07
Vue.js
Erl, 2020-05-24 08:28:07

Why doesn't maxlenght work on number?

In an attempt to find the shortest way to indicate the maximum length of the input, I found such an example, but there is a problem, everything works as long as input type="text"

<input type="text" class="form-control" placeholder="Build Something Awesome" :maxlength="max" v-model="text" />

but when type="number" doesn't work anymore, why is this happening?
<input type="number" class="form-control" :maxlength="max" v-model="text1" />

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Dmitry Gololobov, 2020-05-24
@dGololobov

input number has an attribute max - the maximum number that can be entered into it.
Plus there is a step parameter - the step of changing the number by pressing the arrows
There is also min

0
0xD34F, 2020-05-24
@0xD34F Vue.js

Because .
Hang a watch on the property used in the v-model and adjust the value there if necessary. If there is a need to do this repeatedly, for different inputs, write the appropriate directive .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question