You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
i try to write a from with vee-validate4 and nuxtjs3, i use slot fields, i try to add a checkbox group with a all (will check all),
How to process it ? we have some examples with one checkbox but not with group here my form (all fields are working except checkboxes)
<script lang="ts" setup>
import {Form, Field, ErrorMessage} from "vee-validate";
import * as Yup from "yup";
const successMessage = ref(new String());
const errorMessage = ref(new String());
const schema = Yup.object().shape({
email: Yup.string().required("Email is mandatory.").email("The email entered doesn’t seem right, please try again."),
firstName: Yup.string().required("First Name is mandatory."),
lastName: Yup.string().required("First Name is mandatory."),
company: Yup.string().required("Company is mandatory."),
mobilePhone: Yup.string().nullable().notRequired().when("mobilePhone", {
is: (value: string | any[]) => value?.length,
then: (rule) => rule.matches(/^[0-9]+$/, "Invalid phone number!").min(9, "Phone number must be at least 9 digits!"),
}),
},
[
// Add Cyclic deps here because when require itself
["mobilePhone", "mobilePhone"],
]);
async function submit(values: any) {
console.debug('submit newsletter');
console.debug(values);
await useFetch("/api/newsletter", {
method: "POST", body: values,
onResponse({request, response, options}) {
// Process the response data
return response._data
if (response._data.status === 201) {
successMessage.value = "";
errorMessage.value = "You have successfully subscribed to our newsletter and will receive further emails from us with the latest updates. Thank you!";
}
},
onResponseError({request, response, options}) {
console.debug(response);
if (response.status === 409) {
successMessage.value = "";
errorMessage.value = "Youre already registered or something's wrong";
} else if (response.status === 400) {
successMessage.value = "";
errorMessage.value = "There may be an issue with our server. Please try again later, or send an email to wheels@enata.com";
} else {
successMessage.value = "";
errorMessage.value = "Sorry we couldn’t send the message, there may be an issue with our server. Please try again later, or send an email to wheels@enata.com";
}
}
})
}
</script>
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hello,
i try to write a from with vee-validate4 and nuxtjs3, i use slot fields, i try to add a checkbox group with a all (will check all),
How to process it ? we have some examples with one checkbox but not with group here my form (all fields are working except checkboxes)
and script part
Any ide ? sample ?
Beta Was this translation helpful? Give feedback.
All reactions