Comments (16)
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.
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.
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.
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.
Unfortunately I cannot share whole code. You right it works in your shared example. it's wired!
from react-hook-form.
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.
Shouldn’t u break it into mutiple forms?
from react-hook-form.
Technically it's one form that every field of it is in one step.
from react-hook-form.
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.
How can I call just validation and not submit?
from react-hook-form.
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.
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.
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.
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.
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.
https://codesandbox.io/s/react-hook-form-validationfields-1xb91
from react-hook-form.
Related Issues (20)
- issue + feature request: defaultValue of type `Date` is not applied to`<input type=date>` - with `register` API HOT 4
- issue: Infinite Loop: Submitting FormContext with Nested FormContext causes repeated error rendering HOT 1
- issue: Resolver's return error should properly set formState: {error}
- issue: Validation issue after unmounting fields HOT 4
- issue: ReactNative password field not obscuring text
- i want disabled add button on useField Array when error on 2 required filed
- Support for single input being tied to multiple forms
- issue: fieldArray.fields out of sync with form.watch() after reset HOT 1
- issue: When creating an input that only allows numbers through a controller, entering Korean results in the last digit being erased. HOT 2
- issue: watch not working as expected for nested components using useFormContext
- issue: `getFieldState(..).error` type is incorrect
- issue: register/unregister should affect isDirty in formState
- How to specify the default value type as the object
- issue: form.reset will cause useFieldArray to trigger watch subscription
- issue: radio buttons are not checked when "disabled" property is set HOT 1
- Method to update custom context after the form initialisation?
- issue: getFieldState from useFormContext does not have latest error state without referencing formState also
- issue: error object from both formState and fieldState are always undefined with useController HOT 1
- issue: Password match validation don't hide error, when input not mentioned in refine() 'path' has changed to valid
- issue: useFieldArray and getFieldState causes react console warnings HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-hook-form.