GithubHelp home page GithubHelp logo

Comments (16)

bluebill1049 avatar bluebill1049 commented on May 7, 2024

any chance you can give me the entire code?

the following example seems to be ok.

https://codesandbox.io/s/priceless-williams-7btcl

from react-hook-form.

bluebill1049 avatar bluebill1049 commented on May 7, 2024

do you mean after submit was clicked and the revalidation behavior? at the moment, revalidation is based on input change, but I am planning to introduce another prop to force revalidation to be a specific type.

from react-hook-form.

 avatar commented on May 7, 2024

No, the form is pristine. I click on an input and then I click on the page. Consequently, validation fires and adds a required type validation to errors.

from react-hook-form.

bluebill1049 avatar bluebill1049 commented on May 7, 2024

hmmm its really weird, did you look the example link I shared? it worked there, can you share your code tho?

from react-hook-form.

 avatar commented on May 7, 2024

Unfortunately I cannot share whole code. You right it works in your shared example. it's wired!

from react-hook-form.

 avatar commented on May 7, 2024

I think I got the problem. I try to use it in a multi-step way. In every step I have a submit validation, when it validates on time, in next steps it fires validations onChange!

from react-hook-form.

bluebill1049 avatar bluebill1049 commented on May 7, 2024

Shouldn’t u break it into mutiple forms?

from react-hook-form.

 avatar commented on May 7, 2024

Technically it's one form that every field of it is in one step.

from react-hook-form.

bluebill1049 avatar bluebill1049 commented on May 7, 2024

Then you probably shouldn’t submit the form when it’s not fully fulfilled, maybe have a button which take to the next step. And validate at the end.

from react-hook-form.

 avatar commented on May 7, 2024

How can I call just validation and not submit?

from react-hook-form.

 avatar commented on May 7, 2024

Then you probably shouldn’t submit the form when it’s not fully fulfilled, maybe have a button which take to the next step. And validate at the end.

No I can't. In every step, user should provide valid information!

from react-hook-form.

bluebill1049 avatar bluebill1049 commented on May 7, 2024

I don't think your approach is going to work with how react-hook-form works, because validation will trigger perform via submit button which is an HTML standard.

I suggested if the from is big, you should break them into individual forms and collect them individually. I am working on a funnel which contains 40 plus steps (forms) and that's how we work.

feel free to provide your suggestion tho

from react-hook-form.

 avatar commented on May 7, 2024

Great! I think there should be a validate function like what exist in 'rc-form'. It just validates current fields or the fields name that we provide as parameters.

from react-hook-form.

bluebill1049 avatar bluebill1049 commented on May 7, 2024

thanks for the sharing rc-form :)

After reviewing, I don't think that the direction react-hook-form should be heading, the whole point of making this custom hook is to make things simple by introducing less API if possible.

The last option on top of my head is only register input after previous steps pass.

step A: <input ref={regster} />
step B: <input /> unitl step A pass then <input ref={register} />

I think I have provided my suggestion to make it works, break it into multiple forms or register only when required. hope either one of the methods will work for you.

from react-hook-form.

bluebill1049 avatar bluebill1049 commented on May 7, 2024

ok, I have a better solution may be is good for you.

<form>
  <input /> // step1

  {step2Valid && <><input /><input /></>} // step 2
  {step3Valid && <><input /><input /></>} // step 3
</form>

if you don't render step2 and step3 inputs, then validation won't kick in, start to render rest of steps by validating previous steps.

from react-hook-form.

bluebill1049 avatar bluebill1049 commented on May 7, 2024

https://codesandbox.io/s/react-hook-form-validationfields-1xb91

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.