Closed pavanshinde47 closed 5 years ago
Hi,
here is an example with isFormValid
function. It disables submit button on invalid state case
In my form it showing false even if i fill all the required fields.
on onError isn't firing :(
But it works in example. Maybe you have some issue in your form logic
Yeah, I didn't used validateListener, my bad.
this.setState({ isFormValid: this.form.isFormValid() }) this works in some cases and others it throws error Uncaught TypeError: _ValidationRules2.default[name] is not a function
Hi @NewOldMax Can you check this example
Here I have used PureComponent and handleError = () => { this.setState({ disabled: !this.form.isFormValid(false) }); };
When i type something, the pages becomes unresponsive, can you help me with why this is happening.
I think the problem in your example is that you're using handleError
as both the form onError
handler and also the validatorListener
on the field. If you use isFormValid()
instead of isFormValid(false)
it seems to work ok.
When you call isFormValid(false)
that causes the validatorListener to be called on each field and since validatorListener is calling isFormValid
you get into an infinite loop.
I haven't seen that other error you mentioned (Uncaught TypeError: _ValidationRules2.default[name] is not a function) in your example after changing the isFormValid(false)
to isFormValid()
.
Since isFormValid
was changed, this issue is not acceptable anymore
Hi @NewOldMax ,
Thanks for providing the isFormValid() method to get the form state if its valid or not.
I was trying to use it in the validatorListener but it keeps going into infinite loop. Where do you suggest we should use isFormValid() method?