Skip to content
This repository has been archived by the owner on Apr 12, 2024. It is now read-only.

Input date throws required when date is invalid #8374

Closed
kox opened this issue Jul 28, 2014 · 7 comments
Closed

Input date throws required when date is invalid #8374

kox opened this issue Jul 28, 2014 · 7 comments

Comments

@kox
Copy link

kox commented Jul 28, 2014

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:

<span class="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?

@caitp
Copy link
Contributor

caitp commented 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, required fails to validate, but we don't invalidate the date itself (because we consider empty strings in controls to be valid).

Example:

screen shot 2014-07-28 at 11 11 21 am

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
Copy link
Contributor

caitp commented Jul 28, 2014

Dupe of #6818, #6955, and probably a few others that have already been closed. we're working on this!

@caitp
Copy link
Contributor

caitp commented 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
Copy link
Author

kox commented Jul 28, 2014

Thank you @caitp for your help and sorry for dupe.

@caitp caitp added this to the 1.3.0 milestone Jul 28, 2014
@caitp caitp self-assigned this Jul 28, 2014
@caitp caitp reopened this Jul 28, 2014
@jeffbcross
Copy link
Contributor

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
Copy link
Contributor

Narretz commented 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.

@Narretz Narretz closed this as completed Sep 5, 2014
@caitp
Copy link
Contributor

caitp commented Sep 5, 2014

1.2.x does not support input[type=date] anyways

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants