I am using Laravel 5.6.7 and vue.js
Validation Message
When the validation works in vue.js, it says "The User Name field is required.". Can it be "Please enter user name"? Can I use two custom error messages for same field? Example
- Required: Please enter username.
- Alpha: Please enter alpha chars only.
I am using vee-validate Package for Form Validation
Below is the code in blade
<div class="container-fluid">
<div class="row justify-content-center">
<div class="col-md-12">
<create-user></create-user>
</div>
</div>
</div>
Code in vue.js Component.
<template>
<form role="form" class="row">
<input name="User Name" v-validate data-vv-rules="required|alpha" type="text"
v-model="createForm.UserName">
<p v-if="errors.has('User Name')">{{ errors.first('User Name') }}</p>
<button type="button" @click="validateBeforeSubmit()" class="btn btn-primary">
Create
</button>
</form>
</template>
<script>
export default {
data() {
return {
createForm: {
UserName: ''
}
};
},
methods: {
validateBeforeSubmit() {
this.$validator.validateAll();
}
}
}
</script>