Knob validation demo update
parent
27ca56111e
commit
ba0bf23bc7
|
@ -19,14 +19,12 @@ import { useField, useForm } from 'vee-validate';
|
|||
export default {
|
||||
setup() {
|
||||
const { handleSubmit, resetForm } = useForm();
|
||||
|
||||
const { value, errorMessage } = useField('value', validateField, {
|
||||
validateOnValueUpdate: false
|
||||
validateOnValueUpdate: false,
|
||||
initialValue: 0
|
||||
});
|
||||
const toast = useToast();
|
||||
|
||||
value.value = 0;
|
||||
|
||||
function validateField(value) {
|
||||
if (!value) {
|
||||
return 'The value must be greater than zero.';
|
||||
|
@ -38,9 +36,11 @@ export default {
|
|||
const onSubmit = handleSubmit((values) => {
|
||||
if (values.value > 0) {
|
||||
toast.add({ severity: 'info', summary: 'Form Submitted', detail: values.value, life: 3000 });
|
||||
resetForm();
|
||||
|
||||
value.value = 0;
|
||||
resetForm({
|
||||
values: {
|
||||
value: 0
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -79,12 +79,11 @@ export default {
|
|||
setup() {
|
||||
const { handleSubmit, resetForm } = useForm();
|
||||
const { value, errorMessage } = useField('value', validateField, {
|
||||
validateOnValueUpdate: false
|
||||
validateOnValueUpdate: false,
|
||||
initialValue: 0
|
||||
});
|
||||
const toast = useToast();
|
||||
|
||||
value.value = 0;
|
||||
|
||||
function validateField(value) {
|
||||
if (!value) {
|
||||
return 'The value must be greater than zero.';
|
||||
|
@ -96,9 +95,11 @@ export default {
|
|||
const onSubmit = handleSubmit((values) => {
|
||||
if (values.value > 0) {
|
||||
toast.add({ severity: 'info', summary: 'Form Submitted', detail: values.value, life: 3000 });
|
||||
resetForm();
|
||||
|
||||
value.value = 0;
|
||||
resetForm({
|
||||
values: {
|
||||
value: 0
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -124,12 +125,11 @@ import { useField, useForm } from 'vee-validate';
|
|||
|
||||
const { handleSubmit, resetForm } = useForm();
|
||||
const { value, errorMessage } = useField('value', validateField, {
|
||||
validateOnValueUpdate: false
|
||||
validateOnValueUpdate: false,
|
||||
initialValue: 0
|
||||
});
|
||||
const toast = useToast();
|
||||
|
||||
value.value = 0;
|
||||
|
||||
function validateField(value) {
|
||||
if (!value) {
|
||||
return 'The value must be greater than zero.';
|
||||
|
@ -141,9 +141,11 @@ function validateField(value) {
|
|||
const onSubmit = handleSubmit((values) => {
|
||||
if (values.value > 0) {
|
||||
toast.add({ severity: 'info', summary: 'Form Submitted', detail: values.value, life: 3000 });
|
||||
resetForm();
|
||||
|
||||
value.value = 0;
|
||||
resetForm({
|
||||
values: {
|
||||
value: 0
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
<\/script>
|
||||
|
|
Loading…
Reference in New Issue