I'm attempting to implement a function that validates an input field when it loses focus in nuxtjs. Strangely, the function doesn't trigger when I move out of the input field, but does trigger when I move into another input field and start typing.
<div class="control">
<input class="input" type="text" ref="email" @blur="validateMail()" v-model="email_p" name="email" />
</div>
This is the function call
methods: {
validateMail(){
let value = this.$refs.email.value
let mailformat = /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/
if (value.match(mailformat)) {
//validation passed
} else {
this.msg.email = 'Enter a valid email';
}
},
}