Re: <!DOCTYPE html> Validation input type image with javascript

2013-07-05 15:32, Dennis Nijholt wrote:

> Dear W3 member,

Please note that the www-validator list is an open discussion list, not 
limited to W3C members or W3C staff.

> *<input type="image" name="send" value="send"
> onclick="sendRequestSearch(message.value);">*
> *
> *
> Gives the following error: Attribute value not allowed on element input
> at this point.

Since you are using <!doctype html>, checks are performed against (some 
version of) HTML5, which is work in progress. According to the Candidate 
Recommendation, an image submit button must not have the value attribute:
http://www.w3.org/TR/html5/forms.html#image-button-state-%28type=image%29
(The "value IDL attribute" is defined for it, but this is a different 
thing. You can set the value in a script, but not in markup.)

> But when I change it in type button it's allowed

That's because different rules apply to it.

> In my humble opinion it must be correct too then.

In classic (SGML or XML) validation for HTML, it was impossible to set 
syntax rules where the allowdness of an attribute depends on the value 
of another attribute. In HTML5, such rules are possible, and used.

I'm not sure of the background, but I'm pretty sure this is a conscious 
decision, not an oversight. In the very old days, some browsers used the 
value attribute value as the alternate text when the browser was unable 
to display the image. This is why that attribute was used to some 
extent, but nowadays everyone should use the alt attribute (defined for 
this very purpose) instead.

Using a value attribute would be rather pointless, since it is not 
expected to contribute to the form data. In some browsers it does, but 
it would be a useless risk to rely on that. And image submit button, 
when clicked on, contributes two values, with names zzz.x and zzz.y 
where zzz is the value of the name attribute (in your case, "send", but 
due to name="send") and with the relative coordinates of the clicked 
location as the values.

So I think the value attribute is forbidden because it would not be 
useful and using it could create a wrong illusion of working.

Yucca

Received on Friday, 5 July 2013 14:39:01 UTC