// this is the errors object errors : []
addNewPage : function(){
axios.post('/api/newpage', {
// data to send
name : this.name,
direction : this.direction,
language_id : this.language_id,
})
// success
.then( response => alert('Success'))
// errors
.catch( error => {
if (error.response.status == 422) {
this.errors = error.response.data.errors
}
})
event.target.reset();
},
if the form has erros laravel will show errors in the span element above, So my question how to clear the validation errors on @keydown for every input
If you want to add this automatically to all of you inputs the easiest way is to extract you input to a component where you pass the name as a prop but I tried this approach and found it didn't really help much so went back to just adding the key down event on each input.