I have a form built as functional component using Material ui
which contains markups like below
<form className={classes.container} onSubmit={show}>
<Grid container item xs={12} alignItems="center">
<input
accept=".xlsx,.xls"
className={classes.input}
id="text-button-file"
required
multiple
type="file"
onChange={getfileToUpload}
/>
<Button type= "submit" className={classes.reTest}>
Show
</Button>
</Grid>
</Form>
Now, in my container component, i want to validate if file is really uploaded or not, if not then want to display a validation error message that "Please upload file", but at present if file is not available its giving error as "An invalid form control with name='' is not focusable" in console. Below is my validation function.
valid = () => {
debugger;
if (!this.state.fileName) {
return false;
}
else{
return true;
}
}
What's wrong here? How to use file upload inbuilt validation?