Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.
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

Closed

Description

@kox

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?

Activity

  1. caitp commented on Jul 28, 2014

    @caitp
    Contributor

    @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

  2. caitp commented on Jul 28, 2014

    @caitp
    Contributor

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

  3. caitp commented on Jul 28, 2014

    @caitp
    Contributor

    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

  4. kox commented on Jul 28, 2014

    @kox
    Author

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

  5. added this to the milestone on Jul 28, 2014
  6. self-assigned this
    on Jul 28, 2014
  7. reopened this on Jul 28, 2014
  8. jeffbcross commented on Jul 28, 2014

    @jeffbcross
    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.

  9. Narretz commented on Sep 5, 2014

    @Narretz
    Contributor

    This is fixed in master. Due to how validation is handled in 1.2.x I don't think it'll be fixed there.

  10. caitp commented on Sep 5, 2014

    @caitp
    Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions