Reputation: 103
How can we disable future dates from the material UI datepicker. What I see is that it does not accept any proptypes as disableFuture
or past
.
Here is the github link to the repo sandboxlink
Upvotes: 2
Views: 7298
Reputation: 111
You can add InputProps={{ inputProps: { max: "2017-05-29" } }}
to your <TextField />
then it will work. For example I took "2017-05-29"
is the maximum date. I have updated the same in the sandbox provided by you.
<form className={classes.container} noValidate>
<TextField
id="date"
label="Birthday"
type="date"
defaultValue="2017-05-24"
InputProps={{ inputProps: { max: "2017-05-29" } }}
className={classes.textField}
InputLabelProps={{ shrink: true }}
/>
</form>
Upvotes: 3
Reputation: 163
Currently material picker component not fully implemented. Still its uses native input type element. So you can't pass date restriction for future and past. Another way you will create the helper function for the input and validate on each date selection.
But I will suggest better to use this library https://material-ui-pickers.firebaseapp.com/installation suggested by material documentation page.
for reference look the documentation.
https://material-ui.com/demos/pickers/#date-pickers
Upvotes: 0