Giter Club home page Giter Club logo

Comments (5)

bluebill1049 avatar bluebill1049 commented on May 27, 2024

IMO isSubmitting should be true after validation.

not clear on what's reported here.

from react-hook-form.

KaranLala avatar KaranLala commented on May 27, 2024

did you see the codesandbox and see that validation is not working as expected in the second form? i.e. validation is only being applied to the first input in the second form, when it should validate all fields.

This happens when the form is unmounted when isSubmitting is set to true. If this is expected then nothing needs to be fixed.

from react-hook-form.

bluebill1049 avatar bluebill1049 commented on May 27, 2024

did you see the codesandbox and see that validation is not working as expected in the second form? i.e. validation is only being applied to the first input in the second form, when it should validate all fields.

it wouldn't, rhf focus on single field validation at a time by design. if you need multiple use trigger

from react-hook-form.

KaranLala avatar KaranLala commented on May 27, 2024

It's okay if RHF only validates one field at a time, however in this case, it only ever validates the first field. If you enter a value in the first field in the second form, it does not actually validate anything. You can see the image below.

react-hook-form-2

from react-hook-form.

erashu212 avatar erashu212 commented on May 27, 2024

Hi @KaranLala ,

In your InvalidForm you have conditional rendering

if (isSubmitting) return <div>Loading...</div>;

as soon as you click the submit button this sets as true which unmount other elements but validations are still in process for other form field.

when the RHF goes for other field like textarea in your case, found it as unmount that is why validation does not appear.

You can try this way if you want all error message to be appeared

 let {
    control,
    handleSubmit,
    formState: { errors, isSubmitting },
  } = useForm({ criteriaMode: "all" });

from react-hook-form.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.