The onDayChange function is not called where you manually enter invalid text into the text box of the DayPickerInput.
See https://codesandbox.io/s/v6m53q7o47
Select a date - alert is shown
Enter X as the date picker text - no alert
In daypickerinput.js it has
if (onDayChange) {
onDayChange(undefined, {});
}
return;
}
const day = parseDate(value, format, dayPickerProps.locale);
if (!day) {
this.setState({ value });
return;
}
this.updateState(day, value);
perhaps the if(!day) { ... } statement should also call onDayChangedpassing in undefined.
onDayChange only runs if a day is selected from the calendar, but I have the same issue with firing an event from the input. The standard onBlur or onChange events don't run when input text is manually entered. Am I missing something here? I need to be able to validate the input from this field if a user ignores a selection on the calendar but enters invalid text in the input.
I was missing something, input props that you can pass:
inputProps={{ onChange: this.handleInputChange, onBlur: this.handleInputBlur }}
Most helpful comment
I was missing something, input props that you can pass:
inputProps={{ onChange: this.handleInputChange, onBlur: this.handleInputBlur }}