This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
changeHandler = event => { | |
const name = event.target.name; | |
const value = event.target.value; | |
const updatedControls = { | |
...this.state.formControls | |
}; | |
const updatedFormElement = { | |
...updatedControls[name] | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
constructor () { | |
super(); | |
this.state = { | |
formIsValid: false, //we will use this to track the overall form validity | |
formControls: { | |
name: { | |
value: '', | |
valid: false, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
const Radio = props => { | |
let formControl = "form-control"; | |
if (props.touched && !props.valid) { | |
formControl = 'form-control control-error'; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
const Select = props => { | |
let formControl = "form-control"; | |
if (props.touched && !props.valid) { | |
formControl = 'form-control control-error'; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
gender: { | |
value: '', | |
placeholder: 'What is your gender', | |
valid: false, | |
touched: false, | |
validationRules: { | |
isRequired: true, | |
}, | |
options: [ | |
{ value: 'male', displayValue: 'Male' }, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
constructor() { | |
super(); | |
this.state = { | |
formControls: { | |
age: { | |
value: ''. | |
placeholder: 'What is your age', | |
valid: false, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
const Password = props => { | |
let formControl = "form-control"; | |
if (props.touched && !props.valid) { | |
formControl = 'form-control control-error'; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
const Email = props => { | |
let formControl = "form-control"; | |
if (props.touched && !props.valid) { | |
formControl = 'form-control control-error'; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
const TextArea = props => { | |
let formControl = "form-control"; | |
if (props.touched && !props.valid) { | |
formControl = 'form-control control-error'; | |
} |