react-datetime
react-datetime copied to clipboard
How to set isValidTime?
Hello, first of all, I am really love this one.!!!!
After I read the document file, I know I can set isVaildDate, but how to set isVaildTime?
Because now I am implementing booking meeting function, it needs to make sure that the time that user selects is not the past.
Thank you so much
Would love an answer to this as well! It's easy to prevent a user from picking a past date, but I can't figure out how to prevent them from picking a past time. (For instance, today three hours ago).
I made temporary workaround for that. In my case, I'm validating if start time- selected by a user - is before end date and is not in the past:
handleStartDateChange = () => {
const isValid = this.isStartDateValid(start);
if (isValid) {
this.setState({ start });
}
}
isStartDateValid = (curren) => {
const min = moment();
const end = this.state.end;
return (current.isSame(start) || current.isAfter(start)) && (current.isSame(end) || current.isBefore(end));
};
render() {
return (
<DateTimePicker
value={this.state.start}
dateFormat="MM.DD.YYYY"
timeFormat="HH:mm"
onChange={this.handleStartDateChange}
isValidDate={this.isStartDateValid}
/>
)
}
It just validates date twice. User can still switch between hours, minutes, but time is not set. Hope it helped somehow.
Any update on this?
@madCode exactly what I'm looking for today. Is this possible to accomplish? Any update?