[Vuejs]-Vee-validate validation message not working in Laravel 5.6.7

3đź‘Ť

in the vee-validate doc,

The field under validation must have a non-empty value. By default,
all validators pass the validation if they have “empty values” unless
they are required. Those empty values are: empty strings, undefined,
null.

-1 is still considered a valid value for required validation. Use specified empty values instead. (Namely: empty strings, undefined, null)

e.g.

<option :value="null" selected>Please select Role</option>

This should trigger the required validation.

Example: https://codepen.io/jacobgoh101/pen/geaqwr?editors=1011

0đź‘Ť

There’s a difference between your naming:

<input name="User Name" v-validate data-vv-rules="required" type="text" v-model="createForm.UserName">
<p v-if="errors.has('User Name')">{{ errors.first('User Name') }}</p>

v-model uses UserName (without spacing). The name-attribute in your input and errors.has + errors.first are using User Name (with spacing). Please make sure you’re naming things exactly the same, both in front-end as well as in back-end (and preferably without whitespace).

Leave a comment