3

Considering 3 dates : myDate1, myDate2, myDate3. I'd like to validate that myDate1 < myDate2 < myDate3

Dates are set by the date picker directive found in angular-ui.

Here is a plunker : http://plnkr.co/edit/FTcJNHxuv3RFtBCUw7Ck

I'm having difficulties founding the right way to do that. I'm using ui-validate but it looks like when a condition is evaluated to false, the model is set to undefined.

Edit : It turns out that model being set to undefined is normal Angular behaviour. However there is a bug in the ui-validate directive. I'll update this post once it's resolved. See : https://github.com/angular-ui/ui-utils/issues/25

Florian F
  • 8,822
  • 4
  • 37
  • 50

1 Answers1

2

Please have a look at this fiddle. http://plnkr.co/edit/p0cq1idV6xTF2LyorQ06?p=preview.

Instead of using ui-validate i used ng-change and an extra scope variable formValid to track the validity of form.

Rajkamal Subramanian
  • 6,884
  • 4
  • 52
  • 69
  • 1
    Thanks but I'd like to keep the form validation provided by AngularJS and not relying on a external variable if possible – Florian F May 08 '13 at 09:47