react-vio-form
React form tool with not any dependencies.
Intro
A lightweight, customizable react component that make easily to manage you web form. require React16+
changeLog
- 1.2.0: form.clearError
- 1.1.0: form.setError|form.getModel|form.submit
Install
Run example
npm start
# (in another tab)
cd example
npm start # runs create-react-app dev server
Usage
quick start
first,Customize your InputGroup Component
InputGroup.js
And then,config your form APP
Field.props:
- component:Your customizable React Component
- fieldName:Form field property name
- regexp:The validate regexp
- message:when field's validation fails,pass to InputGroup props
Form.props:
- onSubmit: will trigger without any error
App.js
callback
<Form onSubmit={//}>
will trigger without any error
<Field onChange={//}>
will trigger when change
App.js
API
form object can control the Form App.
how to get form object:
- formManager.get(id)
- the arguments to the callback function
form API:
- setError(fieldName,message)
- clearError(fieldName)
- getModel()
- submit()
App.js