Hello,
I have a Select2 field in a Vue component and I want to prevent the user to type in numbers. Numbers + text is allowed.
I have searched the web and found no solution.
My code looks like this:
template:
<select2 v-model="eventInput" :options="events" name="ed_kbeid" >
<option disabled value="0">Select one</option>
</select2>
watcher component wich listens to “eventInput”:
eventInput: function(input) {
var regex1 = /\d/g;
var regex2 = /\D/g;
if(input == regex1)
{
if(input == regex2)
{
this.$store.commit('setEventInput', input)
}
else
{
input.value = input.value.replace(regex1, "");
}
}
else
{
this.$store.commit('setEventInput', input)
}
}
Any ideas?