You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Apr 12, 2024. It is now read-only.
Repository navigation
This repository was archived by the owner on Apr 12, 2024. It is now read-only.
Input date throws required when date is invalid #8374
When I implement an input date as required and I insert an invalid date like 4/31/1996, then the validation throws a ng-invalid-required but in the documentation the invalid dates are triggered as $error.date:
<spanclass="error" ng-show="myForm.input.$error.date">Not a valid date!</span>
How is possible to detect when a date is invalid or when was not inserted?
@kox this is the same issue we have with input[type=number] which we will hopefully be able to fix / will already be fixed once #8267 lands.
So what happens is: certain input types have a state in the HTML spec where they are "suffering from bad input". When suffering from bad input, these controls report their value to us as empty. So, required fails to validate, but we don't invalidate the date itself (because we consider empty strings in controls to be valid).
Example:
So, what we need to do is enable native validators (which are already enabled for numbers) for dates, and also make sure that required validation is not run unless they are not suffering from bad input.
Both of these things are being worked on, but I think for now we can mark this issue as a dupe of some other issues regarding this
AND PS, yes I've spoken with Hixie about this, I think it's a really dumb behaviour of HTML, but I guess I haven't made my case very clearly, and it's a bit late now since vendors are already shipping this broken validation API --- but you can read all about it at http://www.whatwg.org/specs/web-apps/current-work/multipage/forms.html
Issue reopened since the cause for this issue is related to other open issues, but the manifestation/behavior is slightly different, and should be accounted for in tests.
Activity
caitp commentedon Jul 28, 2014
@kox this is the same issue we have with
input[type=number]which we will hopefully be able to fix / will already be fixed once #8267 lands.So what happens is: certain input types have a state in the HTML spec where they are "suffering from bad input". When suffering from bad input, these controls report their value to us as empty. So,
requiredfails to validate, but we don't invalidate the date itself (because we consider empty strings in controls to be valid).Example:
So, what we need to do is enable native validators (which are already enabled for numbers) for dates, and also make sure that required validation is not run unless they are not suffering from bad input.
Both of these things are being worked on, but I think for now we can mark this issue as a dupe of some other issues regarding this
caitp commentedon Jul 28, 2014
Dupe of #6818, #6955, and probably a few others that have already been closed. we're working on this!
caitp commentedon Jul 28, 2014
AND PS, yes I've spoken with Hixie about this, I think it's a really dumb behaviour of HTML, but I guess I haven't made my case very clearly, and it's a bit late now since vendors are already shipping this broken validation API --- but you can read all about it at http://www.whatwg.org/specs/web-apps/current-work/multipage/forms.html
kox commentedon Jul 28, 2014
Thank you @caitp for your help and sorry for dupe.
jeffbcross commentedon Jul 28, 2014
Issue reopened since the cause for this issue is related to other open issues, but the manifestation/behavior is slightly different, and should be accounted for in tests.
Narretz commentedon Sep 5, 2014
This is fixed in master. Due to how validation is handled in 1.2.x I don't think it'll be fixed there.
caitp commentedon Sep 5, 2014
1.2.x does not support input[type=date] anyways