Linx
Linx

Reputation: 763

Vue input mask letters only

I am using vue-the-mask and I have a simple name field. All I want is for it to only allow letters. I am not very good with regex so I'd really appreciate some help. Thanks.

<input type="text" v-model="cardName" v-mask="/[A-Za-z]/">

Currently that is not allowing any characters in the input field.

Upvotes: 0

Views: 10111

Answers (2)

Timurhan Kaya
Timurhan Kaya

Reputation: 9

you can use v-mask="S*" . S means: [A-Za-z] , * means: infinity length

Upvotes: 0

Nematjon Abdulloev
Nematjon Abdulloev

Reputation: 11

If you want only letters, but don't know the length try -> /[A-Za-z]{0,}/.

It will allow only letters with no limit. I am using vue-inputmask package. The problem I am facing is how to dynamically apply mask or regex based on input value.

Upvotes: 1

Related Questions