How to handle HTML5 type input date with localization?

I have some kind of date field in my application (supported by rails) and my locale is pt-BR (dd / mm / yyyy).

I know some browsers (like Chrome) support input type = date and in these browsers I would like to use the native datepicker and the date format (presentation format) is shown accordingly with the browser locale setting, although the field value (wire format) is still in ISO yyyy-mm-dd format.

In other browsers that don't support it (Firefox for example), I use the datepicker provided by javascript where the user focuses the field and the date is displayed with my standard pt-BR format (presentation format is wire format, localized).

I am switching between these two types via Modernizr.

However, the value (wired format) passed to the server is different depending on the approach, and I need to get the value on my server to be equal regardless of the user's browser.

How do I handle this situation? Should I ignore the type input date and only use one approach (change the type to text)?
Or do I need to format the value before sending it via javascript to "delocalize" the value?

Thanks in advance.

+3
javascript date html5 ruby-on-rails modernizr


source to share


No one has answered this question yet

See similar questions:

664
Is there a way to change the input format = "date"?

or similar:

2102
How do I get the current date in JavaScript?
1865
How to format a JavaScript date
1658
How to return only date from SQL Server DateTime datatype
664
Is there a way to change the input format = "date"?
536
Is there a float input type in HTML5?
343
How do I set the default date value for today's input type?
42
How do I check if the input date is today's date?
five
How to detect browser format for input [type = date]
3
How to check HTML5 date format
3
date confirmation in date format for input date



All Articles
Loading...
X
Show
Funny
Dev
Pics