WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
NEW
269641
checkValidity() of input[type="date"] returns an unexpected result when an entered value is replaced by an empty string.
https://bugs.webkit.org/show_bug.cgi?id=269641
Summary
checkValidity() of input[type="date"] returns an unexpected result when an en...
ef81sp
Reported
2024-02-17 00:02:36 PST
Sample on JSFiddle:
https://jsfiddle.net/xL581koz/
[Summary] - After entering a value in input[type="date"], setting an empty string "" will cause checkValidity() to return false, despite the validityState values being correct. - So the form cannot be submit. - No issues occur when using form reset to clear the value. [Expected] For the condition, - checkValidity() returns true. - The form can be submitted successfully. [How to reproduce] 1. enter a valid value in the input[type="date"] of the form. 2. set an empty string ("") to the input element in JS.
Attachments
Add attachment
proposed patch, testcase, etc.
Radar WebKit Bug Importer
Comment 1
2024-02-24 00:03:14 PST
<
rdar://problem/123549879
>
Anne van Kesteren
Comment 2
2024-09-02 03:29:08 PDT
I can also reproduce this for other form controls:
https://software.hixie.ch/utilities/js/live-dom-viewer/?%3Cinput%20type%3Dtime%3E%0A%3Cscript%3E%0Ainput%20%3D%20document.querySelector(%27input%27)%0Ainput.value%20%3D%20%2212%3A12%22%3B%0Ainput.value%20%3D%20%22%22%3B%0Aw(input.checkValidity())%0A%3C%2Fscript%3E
It seems that the problem is that as soon as a value is set some state gets initialized that is not reset when the value is "removed" again.
Anne van Kesteren
Comment 3
2024-09-02 05:25:14 PDT
The problem appears to be that BaseDateAndTimeInputType::hasBadInput() starts returning true when input is set to the empty string after it's been non-empty and valid.
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug