Mr. Roshan
Mr. Roshan

Reputation: 1805

react-datepicker accepting older dates those are disabled using minDate property

I am using react-datepicker just like below having minDate property.

<DatePicker
  className="form-control"
  minDate={new Date()} 
  selected={this.props.GrantExpiryDate} 
  onChange={(e) => { this.props.onGrantExpiryDateSubmit(e); }} 
  disabled={disableControl} />
  {this.props.GrantExpiryDate == null ? <div className={styles.requiredValidation}>Please select a date</div> : ''}

If I select the Date by using DatePicker its worked fine as shown in the snap.

enter image description here

but when I entered date by manually typing in the date picker control it's allows me to enter older dates those are disabled.

enter image description here

I know this can be handled through the custom function but still this is not behavior which i was expecting from minDate property.

Is there any property or something to overcome this problem.

Upvotes: 0

Views: 986

Answers (1)

kkangil
kkangil

Reputation: 1746

try to use this

<DatePicker
  ...
  onChangeRaw={e => e.preventDefault()}
/>

Upvotes: 1

Related Questions