Prevent Opera browser from enriching HTML5 fields
Asked Answered
W

2

6

I'm using loads of inputs with HTML5 types (such as 'date' or 'time') using the jQuery Tools library. Some browsers (like Opera) automatically recognize that and, for example, transform the <input type="time" /> into a time input.

However, I do not want that behavior (since Opera's time input does not include seconds). Is there any common HTML5 way of disabling such special behavior?

Thanks, Remo

Wacker answered 15/2, 2011 at 13:39 Comment(6)
That's the purpose of the html5 types to have special UI - the simplest way is to use other types - like just type=text.Artair
As Jakub said, those types ARE the "HTML5 way" of doing things. Use CSS classes and then do whatever you want to to the elements with jQuery.Chaps
Calling 'HTML classes' 'CSS classes' makes even less sense when you're only dealing with them in the context of JavaScript. sigh.Niccolite
i really don't have a problem with opera here, since their implementation is good, i hate the way chrome handles html5 form fields, especially date, its terribleRefluent
Chrome also doesn't show deconds. Seems like type='time' might not be the right feature for you (at least not until it's more customisable). Just use type='text'.Pekan
You all are right, type='time' is not the right feature for me because it's giving to much control to the browser itself. Thank you guys!Wacker
H
5

As most of the commenters on the original question already stated: No, there is no "common HTML5 way" to prevent this behavior.

Even if so, you shouldn't. You're effectivly asking Opera to ignore something you asked for in the first place: a special UI.

Hett answered 15/2, 2011 at 13:58 Comment(1)
...and even worse: you prevent users from taking advantage of a general UI for custom input types.Emelinaemeline
C
9

If you want a time element on Opera to display seconds, add the attribute step="1", you can get milliseconds by setting step="0.1" and step=60 will give you the default hh:mm again. This also works in Chrome (tested in 9.0.597.98 beta).

Compliment answered 15/2, 2011 at 14:22 Comment(5)
Looks like you saved his day. :)Hett
Thanks, this actually did me a big favor;)Wacker
If someone wants to read the (working draft) of the HTML5 specification: w3.org/TR/html5/states-of-the-type-attribute.html#time-state It says: "The default step is 60 seconds."Dermato
@Remo, by the way, take a look at this: meta.stackexchange.com/questions/62252/…Dermato
@DenilsonSá To be fair I think @Hett answered his question correctly, this is more of an alternative approachCompliment
H
5

As most of the commenters on the original question already stated: No, there is no "common HTML5 way" to prevent this behavior.

Even if so, you shouldn't. You're effectivly asking Opera to ignore something you asked for in the first place: a special UI.

Hett answered 15/2, 2011 at 13:58 Comment(1)
...and even worse: you prevent users from taking advantage of a general UI for custom input types.Emelinaemeline

© 2022 - 2024 — McMap. All rights reserved.