Skip to content

input type="date" fails validation when using locale specific methods from localizations/  #2359

Closed
@tyomitch

Description

@tyomitch

https://jqueryvalidation.org/date-method/ says: This method is deprecated and will be removed in version 2.0.0.
Please don't use it, since it relies on the Date constructor, which behaves very differently across browsers and locales. Use dateISO instead or one of the locale specific methods (in localizations/ and additional-methods.js).

So we're using localization/methods_pt.js, and observing that it causes validation of date inputs to always fail, because they are unconditionally validated using the deprecated method, and not its suggested replacements.

Environment

  • jquery@3.5.1
  • jquery-validation@1.19.2
  • jquery-validation-unobtrusive@3.2.11
  • Chrome 86.0.4240.111

Steps to reproduce

  • https://jsfiddle.net/1ua63jx0/
  • focus into and out of the date input: it gets a red border, indicating class="input-validation-error"
  • if localization/methods_pt.js is not loaded, then the validation succeeds -- even though our actual date format conforms to methods_pt

This is because date input value is always in ISO format, regardless of the display format (reference)

Expected behaviour

  • normalizeAttributeRule should match date input type with dateISO rule, instead of date rule.

Metadata

Metadata

Assignees

No one assigned

    Labels

    staleUsed to mark stale issues

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions