Tips for stopping a custom field from validating during input with VeeValidate

I am encountering an issue with form validation in which all fields are validating upon clicking the "Submit" button except for a custom field. Here is the structure of my form:

<template>
  <Form v-slot="{ validate }" :validation-schema="simpleSchema">
    First name:
    <div>
      <Field v-slot="{ field, meta }" name="firstName">
        <input v-bind="field" type="text" />
        {{ meta.validated }}
        {{ meta.valid }}
      </Field>
      <ErrorMessage name="firstName" />
    </div>
    Last name:
    <div>
      <Field v-slot="{ field, meta }" name="lastName">
        <input v-bind="field" type="text" />
        {{ meta.validated }}
        {{ meta.valid }}
      </Field>
      <ErrorMessage name="lastName" />
    </div>
    Item:
    <div>
      <InputText name="item" />
      <ErrorMessage name="item" />
    </div>

    <div>
      <button @click="validate">Submit</button>
    </div>
  </Form>
</template>

<script setup>
import { Form, Field, ErrorMessage, configure } from 'vee-validate';
import * as yup from 'yup';
import InputText from './InputText.vue';

configure({
  validateOnBlur: false,
  validateOnChange: false,
});

const simpleSchema = {
  firstName: yup.string().required(),
  lastName: yup.string().required(),
  item: yup.string().required(),
};
</script>

Within this setup, I also have a custom field structured like this:

<template>
  <input v-model="value" type="text" />
  {{ meta.validated }}
  {{ meta.valid }}
</template>

<script setup>
import { useField } from 'vee-validate';

const props = defineProps({
  name: String,
});

const { value, meta } = useField(props.name);
</script>

If you want to see an example, you can check out this link.

Currently, the custom field Item is evaluating immediately upon entry rather than waiting for the "Submit" button click. How can I adjust this so that Item only validates when the "Submit" button is clicked?

Answer №1

To resolve this issue, consider utilizing the following parameter:

const { data, details } = useElement(props.title, undefined, { checkOnInputUpdate: false });

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Unlock the power of polymer iron-ajax by seamlessly linking input element data to the iron-ajax's body attribute

Having some trouble binding data from an input element to the "body" attribute of iron-ajax. In the past, using core-ajax in Polymer 0.5, I could easily bind values like so: <core-ajax id="ajax" method="POST" contentTy ...

Stop or abort any pending API requests in Restangular

I am currently working with an API service: var SearchSuggestionApi = function (Restangular) { return { getSuggestion: function (keyword) { return Restangular.one('search').customGET(null, {keyword:keyword}); } }; }; SearchS ...

What is the best way to retrieve an axios response in Vue.js using a v-on:click event with asynchronous functions and try/catch blocks?

Can someone assist me? I am attempting to retrieve an object response from an API using axios in an async function with try and catch blocks. Currently, when I make the request, I receive: Promise { pending }. How can I access my object? Here is a snippet ...

A guide to resolving a minor issue when transitioning ".slice()" to setup() as a computed function

Currently, I am utilizing Vuejs3 and attempting to transition .slice(0,3) (which limits v-for to 3) into a computed function within the setup(). This adjustment is aimed at restricting the number of elements in a v-for loop, particularly one that is nested ...

How come I am unable to reinitialize my array using setState?

Within my camera module, I am aiming to store photos in a bucket every time three photos are taken. Utilizing state in react, I save the image blobs in an array. Initially, everything functions flawlessly for the first three snapshots; however, subsequentl ...

React js: Changing Material-UI functional code to class component results in TypeError

After utilizing the material ui login page code, I discovered that it is a functional component. To meet my specific requirements, I decided to convert it into a class component. However, during the conversion process, an error was encountered: "Cannot ass ...

The modal box appears to be malfunctioning

I am attempting to open the abc.html file (located in the same directory) in a modal box. Here is the code I am using, however, it doesn't seem to be working. Any assistance would be greatly appreciated. <!DOCTYPE html> <html> <head ...

Should the page in a single page app using Vue router be reloaded?

I have a question regarding my Vue Router setup. While it works, I am confused about whether it truly qualifies as a single-page app. When I click on a link, the page reloads, which seems to contradict the concept of a SPA. Below is my nginx configuration ...

Loop through an array of values in AngularJS

Here is an example of an array: [ {type:'x', value:'123'}, {type:'y', value:'456'}, {type:'z', value:'789'}, {type:'w', value:'012'}, {type:'q&apo ...

Is it possible to propagate hover events across multiple layers?

I'm encountering an issue with my interactive background and overlay. Currently, when a user hovers over these elements, only the hover event for the overlay is triggered. Is there a way to set it up so that both elements trigger hover events simultan ...

Are there more efficient methods than having to include require('mongoose') in each models file?

Is it possible to only require mongoose once in the main app.js file and then pass it to other files without loading it again? Will the script do extra work every time the same module is required? var mongoose = require('mongoose'); I'm wo ...

Tips for utilizing the replace() function

My project setup can be found here: PLUNKR When selecting the first four words and clicking the Highlight button, the text gets highlighted. However, highlighting the first full sentence and pressing the Highlight button does not work for the entire text. ...

Choose not to alter the display value during keyup and keydown events, while still triggering the change event

$(function(){ $(".cls_user_details select").keyup(function(){ $(".cls_user_details select").val("Profile"); }) }) <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <div class="cls_user_setti ...

Google Map continues to update itself without needing to call render() again

In my current project, I am integrating Google Maps using ReactJS and Redux. However, whenever I interact with the map like clicking on a marker or zooming in, the entire map refreshes and turns gray before redrawing the same map with the marker. Even aft ...

What is the process of converting an Array that is nested within an Object?

I am facing compile errors while attempting to convert an Object containing an Array of Objects. Here is the initial structure: export interface CourseRaw { metaInfo: MetaInfoRaw; gameCode: number; gameText: string; images?: ImageRaw[]; // Having ...

Issue: The hydration process has failed due to a discrepancy between the initial UI and the server-rendered content when utilizing the Link element

Exploring Next.js, I stumbled upon the <Link/> component for page navigation. However, as I utilize the react-bootstrap library for my navbar, it offers a similar functionality with Nav.Link. Should I stick to using just Link or switch to Nav.Link? ...

Are third-party scripts and HTML widgets able to replicate your website's data, including cookies, HTML, and other elements?

Currently, I am in the process of constructing a website that incorporates a third-party weather HTML widget. The widget is sourced from a trusted and reliable source on the web. It consists of a link and small JavaScript tags that are executed once loaded ...

The Highchart column chart is triggering the drilldown event multiple times

I have created a column chart using Highchart and I am facing an issue with the drilldown functionality. Whenever I click on a bar multiple times, the drilldown event triggers multiple times as well. This results in the drilldown event being triggered repe ...

Organize the HTML output generated by a PHP array

There must be a simple solution to this, but for some reason, it's escaping me right now. I've created custom HTML/CSS/JS for a slider that fetches its content from an array structured like this: $slides = [ [ 'img' = ...

Using Puppeteer to cycle through a CSV file and take a screenshot for each individual row?

I am looking to automate screenshotting URLs from a CSV file using puppeteer, but the current code execution is slow as each request waits for the previous one to finish. const csv = require('csv-parser'); const fs = require('fs'); con ...