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

Breaks Chrome input type=date #3

Closed
jeffreydking opened this issue Jul 4, 2012 · 8 comments
Closed

Breaks Chrome input type=date #3

jeffreydking opened this issue Jul 4, 2012 · 8 comments

Comments

@jeffreydking
Copy link

The html5Forms.js addition of step="undefined" to input type=date causes all dates in Chrome's native drop down (Version 20.0.1132.47) to be unselectable.

@jeffreydking
Copy link
Author

Using step="any", as is allowed in the specification (http://www.w3.org/TR/html-markup/input.date.html) works fine.

@jeffreydking
Copy link
Author

If I manually set step="any" in the raw HTML, it is not respected, and is replaced with step="undefined".

However step="1" is respected (only if value is empty), and provides a partial workaround for this bug.

@zoltan-dulac
Copy link
Owner

I will take a look at this issue. Do you have an example that I can look at? Just want to make sure that I'm looking at the same thing as you are.

Thanks

Z.

@jeffreydking
Copy link
Author

Right now, my code is applied to the backend of a cms, so it is not publicly available.

html5Forms.js is called in the head like this:

<script src=https://github.com/zoltan-dulac/html5Forms.js/issues/"path/to/html5forms/shared/js/html5Forms.js" data-webforms2-support="all" data-webforms2-force-js-validation="true"></script>">
<script src="path/to/html5forms/shared/js/modernizr.com/Modernizr-2.5.3.forms.js"></script>
<script src="path/to/html5forms/shared/js/html5Forms.js" data-webforms2-support="all" data-webforms2-force-js-validation="true"></script>

The HTML that generates the issue is:

<input type="date" id="reg_date" name="reg_date" required="required" style="width:100px;" />

Once the javascript is run, it becomes:

<input type="date" id="reg_date" name="reg_date" required="required" style="width:100px;" step="undefined" min="undefined" max="undefined" class="wf2_valid">

Chrome chokes on the step="undefined" code, as this is non-standard. If I use the developer tools and change it to step="any", all works as expected.

However, if I edit the raw HTML to include step="any":

<input type="date" id="reg_date" name="reg_date" required="required" style="width:100px;" step="any" />

This is ignored by the javascript and becomes:

<input type="date" id="reg_date" name="reg_date" required="required" style="width:100px;"  step="undefined" min="undefined" max="undefined" class="wf2_valid">

Alternatively, if I add step="1" to the HTML:

<input type="date" id="reg_date" name="reg_date" required="required" style="width:100px;" step="1" />

The javascript respects this, and all works as expected:

<input type="date" id="reg_date" name="reg_date" required="required" style="width:100px;"  step="1" min="undefined" max="undefined" class="wf2_valid">

But if the value parameter is assigned:

<input type="date" id="reg_date" name="reg_date" value="2012-07-05" required="required" style="width:100px;" step="1" />

The javascript, once again, ignores the step="1" and replaces it with step="undefined".

<input type="date" id="reg_date" name="reg_date" value="2012-07-05" required="required" style="width:100px;"  step="undefined" min="undefined" max="undefined" class="wf2_valid">

Generally, I think it is bad form to add min="undefined", max="undefined", and step="undefined" at all. Perhaps your inner workings depend on this in some way, but if they are undefined, I would expect that these parameters be omitted rather than added as non-standard markup that may break in future browser implementations (as has happened with Chrome).

Other than this, the code is fantastic. I greatly appreciate all the hard work you put in to this. You have made the web a better place!

@jeffreydking
Copy link
Author

If the above is insufficient to recreate the issue, email me at jeff at kingdesk dot com, and I will get you access to the WordPress backend where this is being applied.

@jeffreydking
Copy link
Author

I have prepared test case that demonstrates the bug(s) here: http://test.kingdesk.com/date-input/

@erutan
Copy link
Contributor

erutan commented Jan 27, 2015

FYI the test case page (http://test.kingdesk.com/date-input/) works fine in current chrome on OS X.

@zoltan-dulac
Copy link
Owner

@kingjeffrey , @erutan : Thanks for your work looking into this. Yeah -- it seems like Google fixed this in Chrome already, so I guess we can close this. I'll take a look at #13 as well and if it's the same, I'll close that as well.

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

No branches or pull requests

3 participants