I am writing new form as below in vue js. In name field i want to enter like "John Doe". Basicly its a combination of first name and last name.
I tried some regex expressions instead of alpha validation for name. but its also not allowing me to type space bar. When i hit space bar it is not showing space between the words.
validations: {
name: {
required,
isNameValid:helpers.regex('isNameValid',^[a-zA-Z0-9_ ]*$),
minLength: minLength(4)
},
<input
v-model.trim="$v.name.$model"
name="name"
label="Name"
:error="$v.name.$error"
@input="delayTouch($v.name)"
/>
<script>
import {
validationMixin
} from "vuelidate";
import {
required,
alpha,
minLength,
email,
helpers
} from "vuelidate/lib/validators";
import { createNamespacedHelpers } from "vuex";
const {
mapGetters: mapQuoteGetters,
mapState: mapQuoteState
} = createNamespacedHelpers("mydata");
// For delayed validation
const touchMap = new WeakMap();
export default {
name: "MoveInfo",
mixins: [validationMixin],
data() {
return {
name: ""
};
},
computed: {
...mapQuoteState({
mydata: "mydata"
})
},
methods: {
delayTouch($v) {
$v.$reset()
if (touchMap.has($v)) {
clearTimeout(touchMap.get($v))
}
touchMap.set($v, setTimeout($v.$touch, 1000))
}
},
validations: {
name: {
required,
alpha,
minLength: minLength(4)
},
Can anybody tell me how to resolve this and what wrong with my regular expression?