Form fields custom validation message
See original GitHub issueHi, how can I use Laravel for validation?
<template>
<div>
<form>
<v-card>
<v-card-text>
<v-row>
<v-text-field
label="Nome"
v-model="data.name"
name="name"
id="name"
:rules="rules.name"
></v-text-field>
</v-row>
<v-row>
<v-text-field
label="Descrizione"
v-model="data.description"
name="description"
id="description"
multi-line
></v-text-field>
</v-row>
<v-row>
<v-checkbox
label="Attivo"
name="status"
id="status"
v-model="data.status"
input-value="1"
success
></v-checkbox>
</v-row>
</v-card-text>
<v-card-row actions>
<v-btn flat @click.native="submit" :loading="loading" type="submit">Salva</v-btn>
</v-card-row>
</v-card>
</form>
</div>
</template>
<script>
import swal from 'sweetalert'
export default {
data() {
return {
data: {
name: null,
description: null,
status: null
},
rules: {
name: []
},
loading: false
}
},
methods: {
submit() {
this.loading = true;
this.$http.post('api/categories')
.then(response => {
this.loading = false;
swal('', response.data.message, response.data.status);
}, error => {
this.loading = false;
let errorType = error.response.status;
if (errorType == 422) {
let self = this;
_.forEach(error.response.data, (v, i) => {
self.rules[i] = [() => v[0]]
});
} else {
swal(errorType.toString(), response.data.message, response.data.status);
}
})
}
}
}
</script>
Issue Analytics
- State:
- Created 7 years ago
- Reactions:1
- Comments:8 (1 by maintainers)
Top Results From Across the Web
HTML5 form required attribute. Set custom validation message?
In my case I want to check that the value is a number before posting but I can't use the type="number" attribute (for...
Read more >Client-side form validation - Learn web development | MDN
Client-side form validation sometimes requires JavaScript if you want to customize styling and error messages, but it always requires you to ...
Read more >Form required attribute with a custom validation message in ...
Example: This example shows how to do HTML form required attribute along with setting custom validation message.
Read more >Providing custom error messages for built-in HTML5 form ...
How to customize built-in form validation error messages · Grab the input element(s) with a querySelector / querySelectorAll . · Add an event ......
Read more >How to add a custom validation message for the required field?
Click on the respective form field. On the 'Field Options', you will find the following options.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@beggiatom try this way, but i have some issues on the reset the error-messages after start typing again
@beggiatom thank you for sharing!