[whatwg] pattern-hint

Mark Schenk css at markschenk.com
Tue Jun 29 07:30:31 PDT 2004


As stated in the pattern section [1] it is desirable to have a description  
of the required pattern available to the user. It is suggested to use the  
title attribute for this. However, the current version of the spec also  
recognizes the problems this can pose when it is handled incorrectly by  
page authors, resulting in meaningless error messages.

The spec also suggests a possible solution by adding a new attribute,  
pattern-hint. I would like to see something similar implemented, but in a  
more generic form, namely as the "hint" attribute, which would be  
*required* for any element using the pattern attribute.

Further down in the spec, discussing the help attribute [2], the hint  
attribute is briefly touched upon. It is stated that:

"Note: This [the help attribute] attribute is added mainly because XForms  
has it, to show that it would be trivial to add to HTML as well. However,  
there is some doubt that it is actually a useful feature. The XForms hint  
element is already supported in HTML, as the title attribute."

I do not entirely agree that the HTML title attribute is equivalent to the  
XForms hint element[3], as in the following example which for entering a  
(customer-/tracking-)id as is often used in correspondence between company  
and customer:

<input type="text"
        name="uid"
        title="Correspondence Number"
        pattern="some-regexp-here"
        hint="The correspondence number is a number of the form  
1234-56-789" />

The title describes what the field is about and hint describes in what  
format the data should be entered, which I think are two distinctly  
different things.


So imho, the title attribute should not be used for giving information  
about how the data should be inserted and a separate attribute is  
desirable to get more meaningful errors. An added advantage of using an  
attribute other than  title for this, is that you can make it *required*  
for an element that has a pattern attribute. Note: no-one would prevent  
authors from also providing information about the format in the title  
attribute, to allow for graceful degradation to non-WF2 UA's.

Furthermore I would prefer a more generic attribute like "hint" over  
"pattern-hint" as it is more similar to XForms and it will allow for  
possible expansion to other elements in future versions of the spec.  
XForms allows both URL and inline text for the hint attribute, but for  
WebForms I would suggest only using inline text as there is already the  
help attribute which can be used to refer to more extensive help in  
another document.


Best regards, Mark.

[1]  
http://www.whatwg.org/specs/web-forms/2004-06-27-call-for-comments/#the-pattern
[2]  
http://www.whatwg.org/specs/web-forms/2004-06-27-call-for-comments/#the-help
[3] http://www.w3.org/TR/xforms/slice8.html#ui-commonelems-hint




More information about the whatwg mailing list