Date validation min date not working


#1

I’ve been playing around with this for an hour or so but can’t seem to get the min date validation working on a date input I have. This is the simple html I have:

<input type="date" ng-model="date" min="2014-07-25" required>

Any date I enter before the min causes the “ng-valid” class to be applied. Further, {{date}} is printing the date in exactly the format specified in the angular docs.

Related to this, is there any way to make it impossible to pick a date in the iOS datepicker that is before today? That would be ideal as well. Thanks!


#2

Hi, i exactly have same problem, so i can’t do client-side date validation, can you help us ?


#3

The “min” and “max” attributes are only there for form-validation.
There is no better implementation on mobile devices for this new html5 feature, yet.

Or you are using 3 (yyyy, mm, dd) select inputs instead of the date picker.
For that you could only provide valid values.

Greetz, bengtler


#4

Thank you for your reply. Maybe i missing something, but i d’ont understand why it work like a charm (with safari on mac) on https://docs.angularjs.org/api/ng/input/input[date] and not on my ionic app ?


#5

Yeah it is dependend how this thing is implemented in the browsers.
It also works in Chrome very well.
But you have to consider that safari and mobile safari are different things.

If you use type date, number or select boxes on mobile device the system default behavior is triggered (you see the iOS or Android datepicker… not the browser date picker).

It has nothing to do with ionic… only a mobile - non-mobile thing :wink:


#6

yes sure, only thing i can’t understand is why myForm.input.$valid work correctly with angular and not with ionic ?


#7

I am using this in my template and it works.

Maybe you have another scope issue?


#8

Maybe you can well understand my pb with this example (fork from angular Input[date] doc) with ionic :

but validation work correctly with angular only :


#9

if you use //ajax.googleapis.com/ajax/libs/angularjs/1.2.21/angular.min.js
(this is the last stable angularjs version)
the output looks the same, for me…

Greetz, bengtler


#10

Ho yes you’ve right :blush: Thx a lot !
So it’s due to angular version… hope this fix embed in 1.3 came soon in 1.2 branche