jonhobbs
jonhobbs

Reputation: 27952

Angular-UI datepicker validation error when previously selected date is now disabled

I have an angular-ui datepicker on my site which allows the user to select a delivery date. I'm disabling all dates in the past and all Sundays.

This works fine, the user cannot select a disabled date as expected so the control will never be invalid.

The problem comes when you go to edit the order after the chosen date has passed. The original date on the model is selected in the datepicker even though the date is disabled and the form will not submit because the datepicker is presumably setting $invalid internally and my form controller won't allow invalid forms to be submitted.

The documentation doesn't talk about any validators at all and I need a way of either switching them off (it should be enough that the user can't manually select a disabled date) or working round this issue.

Any help would really be appreciated.

Upvotes: 0

Views: 321

Answers (1)

Rob J
Rob J

Reputation: 6629

The datepicker directive allows for turning off validation in the ngModelOptions - allowInvalid.

Upvotes: 1

Related Questions