简体   繁体   中英

How to Check Form valid or not using Redux-Form

是否有任何 api 可用于检查当前表单是否有效或不使用 REDUX-FORM。

You can try to run code from official documentation - sync validation

But if you need to check validation asyncronously try this example - redux form async validation

Btw you can also call 'this.props.validate()' to trigger form validation.

I found the solution. we can use isValid or isInvalid

import {
  isValid,
  isInvalid
} from 'redux-form'

isValid(formName:String) returns (state) => valid:boolean Returns true if the form is valid, ie has no sync, async, or submission errors. The opposite of isInvalid.

isInvalid(formName:String) returns (state) => invalid:boolean Returns true if the form is invalid, ie has sync, async, or submission errors. The opposite of isValid.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM