Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conflicts with form validation in IE 11 #53

Open
vfaronov opened this issue Aug 9, 2017 · 10 comments
Open

Conflicts with form validation in IE 11 #53

vfaronov opened this issue Aug 9, 2017 · 10 comments
Labels

Comments

@vfaronov
Copy link
Contributor

vfaronov commented Aug 9, 2017

<script src="nodep-date-input-polyfill.dist.js"></script>
<form>
  <input type=date required id=x>
  <button type=button
    onclick="alert(document.getElementById('x').checkValidity())">Submit</button>
</form>

In IE 11, when I pick a date using the polyfill’s picker and click Submit, I get “false”.

If I type something manually into the input and click Submit, I get “true”.

In Firefox, I get “true”.

It seems like IE’s constraint validation doesn’t care if you set the value attribute, only if you set the value property, which the polyfill overrides.

@brianblakely
Copy link
Owner

Hm, the value property matches the spec. Is it possible that IE's validation doesn't respect programmatic values, only user-typed values?

@vfaronov
Copy link
Contributor Author

@brianblakely It seems like IE’s constraint validation doesn’t care if you set the value attribute, only if you set the value property, which the polyfill overrides.

@brianblakely
Copy link
Owner

brianblakely commented Aug 22, 2017

The polyfill sets both the attribute and the property. The property is populated with an ISO date, in accordance with the spec. Does IE expect to see the localized value, which is given to the attribute? If that is the case, then it is an IE bug.

@vfaronov
Copy link
Contributor Author

@brianblakely I’m not sure (not good at JS) but I don’t think the polyfill sets the native value property? Instead it replaces it with its own value property.

The jcgertig/date-input-polyfill doesn’t seem to do that, and doesn’t suffer from this problem.

then it is an IE bug

Well, I would not be surprised if the underlying cause were some IE bug. That bug is not getting fixed, though.

@brianblakely
Copy link
Owner

brianblakely commented Aug 22, 2017

So there is a wrinkle here. I went to test this for myself, and it actually worked correctly. When the element is blank, checkValidity returns false, but when a value is selected via picker, it returns true.

If possible, would you be able to create a CodePen or something that demonstrates the issue for you?

@vfaronov
Copy link
Contributor Author

@brianblakely http://vasiliy.faronov.name/nodep-date-input-polyfill-issue53/
Click the field, pick a date, click Submit. You should see an alert saying “true”. But in IE 11, I see an alert saying “false”.

@brianblakely
Copy link
Owner

brianblakely commented Aug 31, 2017

It's rather bizarre, what I have been able to find is that this bug seemingly only manifests when the field is wrapped in a <form>.

The official demo doesn't use that tag, so that is why it works in IE11.

@vfaronov
Copy link
Contributor Author

I think HTML constraint validation operates on forms and form inputs, not some random inputs. So this doesn’t seem too bizarre to me.

@brianblakely
Copy link
Owner

It actually does work with any input element.

@martinduparc
Copy link

martinduparc commented Aug 27, 2018

Am I wrong thinking that not setting the value would solve the problem?

It is what there are doing on https://wet-boew.github.io/wet-boew/demos/datepicker/datepicker-en.html

Edit: I also noticed that the value is set in the wrong format (08/15/2018 vs the correct 2018-08-15). FWIW, https://github.com/jcgertig/date-input-polyfill works

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

No branches or pull requests

3 participants