vee-validate how to set digit limit between two number?

hidar picture hidar · Feb 2, 2018 · Viewed 12.5k times · Source

I am trying to restrict the number of digits a user can input between 3-6.

For some reason, I can't find how to do that.

this is the code I have to force user to add three digits only

<input type="text"  name='account-field-3' v-validate="'required|digits:3'" placeholder="6" class="form-control" > 

But what I need is between 3-6.

Answer

Igor Martins picture Igor Martins · Feb 2, 2018

You need to use min and max

Max: https://baianat.github.io/vee-validate/guide/rules.html#max

Min: https://baianat.github.io/vee-validate/guide/rules.html#min

<input type="text"  name='account-field-3' v-validate="'required|min:3|max:6'" placeholder="6" class="form-control" >