Sasha
Sasha

Reputation: 5944

How to disable specific dates on DatePickerIOS and DatePickerAndroid?

I have a calendar on react-native, and I need it to have some dates disabled (not choosable by user, i.e. every Tuesday and Friday). I don't see such options in docs

https://facebook.github.io/react-native/docs/datepickerandroid.html

https://facebook.github.io/react-native/docs/datepickerios.html

Is there a way to do that?

"react-native": "0.55.2"

Upvotes: 0

Views: 891

Answers (1)

Priya
Priya

Reputation: 1470

I think you can use this

<DatePickerIOS
      date={this.state.chosenDate}
      onDateChange={(date) => {
        if(date.getDay() != '2' || date.getDay() != '5')  {
          this.setState({chosenDate: newDate})
        }
        else {
          this.setState({error:'you can not select this date ...'})
        }

      }}
    />

Upvotes: 1

Related Questions