react-material-form
react-material-form is a set of react components, for validating forms using material-ui for react.
Install
npm install react-material-form --save
Available validation rules
required, email, letters, number
Usage
Check code available on Github or the code snippet bellow
;;; const isEmptyObject = { forlet prop in obj if ObjectprototypehasOwnProperty return false; return true;}; Component { super props; thisstate = errors: {} formData: {} ; thisonSubmit = thisonSubmit; thisonChange = thisonChange; } { const errors formData = thisstate; const isValidForm = ; if !isValidForm return false; // Handle submit console; } { this; } { return <FormElement onSubmit=thisonSubmit onChange=thisonChange> <div> <MyTextField email id="email" name="email" hintText="Email" fullWidth=true /> </div> <div> <MyTextField required type="password" id="password" name="password" hintText="Password" fullWidth=true /> </div> <div> <MySelectField required name="gender" floatingLabelText="Select your gender" options=label: "Male" value: "male" label: "Female" value: "female" /> </div> <div> <RaisedButton type="submit" label="Submit" primary=true disabled=!/> </div> </FormElement> ; } ;