[whatwg] Text areas with pattern attributes?

On Tue, Aug 25, 2009 at 4:24 PM, Aryeh Gregor<Simetrical+w3c at gmail.com> wrote:
> For that matter, it might be nice if some patterns just refused to let
> you enter anything that doesn't meet the pattern -- but not all,
> clearly. ?E.g., "[ -~]*" to restrict to ASCII would really like to
> just not let you type other characters, but that's not workable for
> ".{10,}" to set a minimum length. ?Possibly this is too much
> complication for the time being, however.

Oh, patterns, I love these. Let's play, let's play!

https://account.nokia.com/acct/register?serviceId=Ovicom&lid=acctregrtnav&lang=es-419

This page (and its relatives) is great for patterns.

Si no halas ustedes Espa?ol podria visitar al: http://translate.google.com/t

Here's our first input:
1. Su nombre de usuario y contrase?a
Nombre de usuario (obligatorio)

Ingrese 3 a 32 caracteres. El nombre de usuario s?lo puede contener
n?meros, '.', '-' y '_'.

[            ]

Google's translation:
1. Your username and password
Username (required)

Revenue [should be "Enter"] 3 to 32 characters. The username can
contain only numbers, '.', '-' And '_'.

Ah, but you don't speak Spanish? ok, let's try the English language
version of that page:

https://account.nokia.com/acct/register?serviceId=Ovicom&lid=acctregrtnav&lang=en-US
1. Your user name and password
User name (mandatory)

Please enter 3 to 32 characters. User name can only contain letters,
numbers, '.', '-' and '_'.

And no, Google did not make a mistake in its translation from Spanish
(just check the other Spanish).

Anyway, let's try entering a value into this text field, please allow
me to suggest ".123", it's a perfectly reasonable thing according to
both sets of instructions.

The results from English are:
"Your user name can only contain numbers and letters, not symbols."

Patterns are wonderful things, but people rarely get them right. I
don't think Ovi is uniquely talented here. I suppose that in theory if
Ovi were to have had a pattern input object and relied on the user
agent to give the user a set of valid characters, they might not have
provided the wonderful strings they did (which are well... both
breathtaking and spectacular), however, I doubt that.

OTOH, as someone who is working on an embedded system (Maemo 5), I can
say that we've asked our Input Method team for the ability to specify
an arbitrary set of allowed characters, and they've refused :). We've
asked them nicely, and repeatedly, and they've insisted it isn't
something they'll support. Among other reasons, they claim it's
confusing :)

(The IM team does not work with Ovi.)

Please note that textareas today support both  "onchange" and
"oninput". I've recently switched from using onchange to oninput for a
tiny niche web app of mine. The ovi example would greatly benefit from
this same change.

Adding a pattern thing would not really help. Especially given how
screwy patterns can be.

If you want to do something with input, the right thing to do is to
disable the submit button and explain to the user why you didn't like
their input. Well, at least, if you can manage to come up with a
proper explanation. If web authors really think they're incapable of
providing correct explanations, they're in trouble, because as noted,
not everyone will have whatever feature you're asking for here today,
which means you'll need to do the work anyway (and please do get it
right, at least in English, if not in Spanish).

Received on Thursday, 3 September 2009 10:07:17 UTC