React Validation
React validation can be easily done using React Redux Validator which will help us to add validator a page with ease.
npm install react-redux
npm install redux-form
Mandatory fields are
React Field exposes input and meta object which contains, which can be used to display error messages
Input (which add's following client events)
Meta: (Redux Form properties)
npm install redux-form
Field
Each field need to be decorated with Redux Form Field,Mandatory fields are
- name (Name will be used to add validation)
- field (Control reference for Redux-Form control to get added into form control)
- component (Rendering the control, binding Redex references, and error notification)
- Decorated inside a form
React Field exposes input and meta object which contains, which can be used to display error messages
Input (which add's following client events)
- onBlur
- onChange
- onDragStart
- onDrop
- onFocus
Meta: (Redux Form properties)
- active
- valid
- touched
- error
- invalid
- visited
- form
- error
- dirty
- autofilled
- submitting
- submitFailed
- pristine
Custom Control decoration with Field
renderField = field =>
<formfieldscontrol
name="name"
name="name"
field={field.input}
<input
{...this.props.field}
name={this.props.name}
Input Control decoration with Field
<input
name=
{...field}
name=
{...field}
Redux Form
While exposing redux form ensure a unique form page name, validation method and warn message passed.
export default reduxForm({
form: 'CustomerPage', // a unique identifier for this form
validate: CustomerPageValidation, // <--- div="" function="" given="" redux-form="" to="" validation="">--->
https://github.com/hariram302/react-kickstart/
warn: CustomerPageWarn // <--- div="" function="" given="" redux-form="" to="" warning="">--->
})(CustomerPage);
Sample
https://github.com/hariram302/react-kickstart/blob/master/client/CustomerPage.jshttps://github.com/hariram302/react-kickstart/
Good blog post. Really very informative and creative contents. These concept is a good way to enhance the knowledge. Thanks a lot
ReplyDeleteBest Regards,
ReactJS Online Training in India
ReactJS Training in Hyderabad
ReactJS Online Training in Hyderabad
ReactJS Online Training
Learn ReactJS Online
ReactJS Training
ReactJS Online Course
React JS Online Training
ReactJS Training Institutes in Hyderabad
ReactJS Training Hyderabad
ReactJS Institutes in Hyderabad
ReactJS Classroom Training in Hyderabad
Best ReactJS Training in India
Learn ReactJS Course in Hyderabad
CourseIng
Great Post, Thanks fir sharing such a informative information.
ReplyDeleteReact JS Online Training
React JS Online Course
React JS Online Training in chennai