This is a question to people who live with the metric system. When entering your height on forms is there a strong expectation that you would enter a value of meters or centimeters?
We've gone with meters on WeightChart.com, but have seen some impossibly tall people wondering why our calculations are way off. We've implemented some sanity checks as a fix, but we'd like to meet people's expectations if there is a co开发者_Go百科nsensus.
Thanks!!
Update: Thank you for your answers, I see that centimeters are preferred. But sanity checks are going to be required to handle either. Yes I realize that my 'answer' isn't really what my question was seeking, sorry about that.
Using centimeters at least protects you from having to deal with a decimal point (or comma). But I—being kind of a zealot when it comes to SI—usually assume that the base units are used, unless the context mandates something else.
For height both meters and centimeters are used sometimes, so your sanity checks probably are best from the user's perspective. Nobody will be 190 meters high (at least I haven't met someone like this) or 1.9 cm.
I can't speak for all metric countries; as they are roughly (COUNT(SELECT countries FROM world) - 2)
; but at least in Norway, the common approach is to use centimeters.
I'd say let a person enter in their height, then either try to parse it or let them choose the measurement type from a dropdown. You'll probably be able to figure out the type with a simple parse algorithm 95% of the time. The rest you can ask people to be more specific.
I'd go with Will's answer. Just adding:
If the input is ^[0-9]{2,3}$
, it's centimeters. If the input is ^[12][,\.][0-9]{1,2}$
, it's meters. If it's anything else, it's time for an error message.
The [,\.]
, by the way, takes care of some European languages using the comma as decimal separator.
精彩评论