[whatwg] question about the input tag attributes

Jukka K. Korpela jkorpela at cs.tut.fi
Wed Apr 13 00:56:18 PDT 2011


Nicola Di Fabrizio wrote:

> is it possible to set a attribute for checking the element
> if it is not empty

Yes, there's the attribute required, see
http://www.whatwg.org/specs/web-apps/current-work/multipage/common-input-element-attributes.html#the-required-attribute

> like
> <input type="text" needed="yes">

Like <input type="text" required>.

No value is needed, it's a "boolean" attribute (somewhat misleading, but 
this name is justified by the logic that the _presence_ or absence of the 
attribute in markup implies a boolean value - true or false - for the IDL 
attribute, a property of the object).

> if needed = yes and the element has no value
> then appears a msgbox like
> "Please input something..."

Something like that, though this has been implemented in a few browsers 
only, e.g. Opera.

> or the msgbox text is also an attribute
> where you can put in your own message.

Well not in markup, but HTML5 specifies the setCustomValidity() method for 
input fields; so you can set your own message using JavaScript.

-- 
Yucca, http://www.cs.tut.fi/~jkorpela/ 




More information about the whatwg mailing list