Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AngularJS : Validating against multiple datepickers

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

like image 701
Florian F Avatar asked Sep 19 '26 18:09

Florian F


1 Answers

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.

like image 51
Rajkamal Subramanian Avatar answered Sep 22 '26 09:09

Rajkamal Subramanian



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!