I have a react functional component built using Material ui form which contains TextField and onChange event is handled in "Container Component". Below is the form code where i need to add required as client side form validation but, its not working. Do i need to add some logic in container component as well?
<form className={classes.container}>
<Grid container item xs={12} alignItems="center">
<TextField
id="outlined-bare"
className={classes.textField1}
defaultValue=""
required
margin="normal"
variant="outlined"
autoComplete="on"
InputProps={{ style: { height: 40 } }}
onChange={(e) => handleChange(e, 'Name')}
/>
and here is event handler in container component like below
setInput = (e, source) => {
e.preventDefault();
switch (source) {
case "Name":
this.setState({
...this.state,
Name: e.target.value
})
break;
default:
this.setState({...this.state})
break;
}
}
return (
<div>
<Drawer
route={routes.abc}
history={this.props.history}
handleChange={this.setInput}
/>
</div>
)
What's wrong, and is missing? I am new to ReactJs. Kindly suggest.
Submitfunction which will read the value entered in TextField and call redux action. I need validation to be handled before it..ThanksTextFieldvalue inside submit function? In this case, where isrequiredworking?