Coder Social home page Coder Social logo

Comments (4)

sideshowbarker avatar sideshowbarker commented on May 11, 2024

Am I missing something here, or did I unveil a validator bug?

The validator conforms to the requirements in the spec here, but the wording could be more clear. So I changed it such that the error message emitted for this case is now this:

The first child option element of a select element with a required attribute, and without a multiple attribute, and without a size attribute whose value is greater than 1, must have either an empty value attribute, or must have no text content.

Previously it wasn't clear but by “size” the message was meant to be referring to what the HTML spec more precisely calls “display size”—an abstract term of art coined in the spec to define the requirement. But in this there’s no reason it needs to state the requirement through that indirection, because it can instead be stated concretely in terms of the size attribute. So that's what I made it say now.

So I'm going to go ahead and close this out but if you believe some further fix to the validator is needed here—e.g., if you want to propose some different wording or think the validator is not actually matching the requirements in the spec here—please feel free to reopen it.

On a related note as far as the spec goes, IMHO the actual language in the spec for this requirement could be stated more precisely and clearly, so I filed a spec bug suggesting it be refined: https://www.w3.org/Bugs/Public/show_bug.cgi?id=28150

The spec currently says this:

If a select element has a required attribute specified, does not have a multiple attribute specified, and has a display size of 1, then the select element must have a placeholder label option.

And I suggested that it be changed to this:

If a select element has a required attribute specified, does not have a multiple attribute specified, and does not have a "sizes" attribute with a value greater than 1, then the select element must have a placeholder label option.

Finally, if you want an explanation of the rationale behind that particular spec requirement, Jukka’s explanation from the following e-mail message is pretty good—

https://lists.w3.org/Archives/Public/www-validator/2014Apr/0020.html

from validator.

astorije avatar astorije commented on May 11, 2024

Hey @sideshowbarker, thanks for your answer. Detailed I must say, but I am still very confused, if not more.

To my understanding of the (suggested) spec wording and the new error message: the select element has the required attribute specified and does not have a multiple attribute specified. So I guess I meet this error because I have a "display size of 1", and I have no idea what that means...

I tried to remove the selected attribute as per Jukka's explanation but it didn't change anything. And again, my select has 3 elements, that's what I understand with "size".

from validator.

sideshowbarker avatar sideshowbarker commented on May 11, 2024

To my understanding of the (suggested) spec wording and the new error message: the select element has the required attribute specified and does not have a multiple attribute specified. So I guess I meet this error because I have a "display size of 1", and I have no idea what that means...

@astorije Is there something unclear about the current error message shown at http://goo.gl/mjto0R ?

That error message doesn't now say anything about "display size of 1"; instead it explicitly says, without a size attribute whose value is greater than 1. Is there some way I could make that more clear?

So as far as what you'd need to do to to make your markup valid, you have two choices:

A. Use a “placeholder option label”: <option value="">Select a validation option</option>

<select class="form-control" id="validation" required>
    <option value="">Select a validation option</option>
    <option value="no-validation">No validation</option>
    <option value="simple-validation" selected>Simple Validation</option>
    <option value="recursive">Recursively validate multipart documents</option>
</select>

B. Use a size attribute with the appropriate value:
<select class="form-control" id="validation" required size=3>

<select class="form-control" id="validation" required size=3>
    <option value="no-validation">No validation</option>
    <option value="simple-validation" selected>Simple Validation</option>
    <option value="recursive">Recursively validate multipart documents</option>
</select>

The choice just depends on what you prefer to show to the user in the UI: either a normal select drop-down menu, or a 3-row multi-select list box.

I think most people go with the normal select drop-down menu, which is why the spec tries to help here by requiring a “placeholder option label” for this case.

Do you have some suggestion about how I could change the wording of the error message to help users understand that the two solutions are A and B above? Or maybe @Hixie has a suggestion.

from validator.

sideshowbarker avatar sideshowbarker commented on May 11, 2024

OK I added some clarifying text to the error message such that it now also says, “Consider either adding a placeholder option label, or adding a size attribute with a value equal to the number of option elements.” Further feedback/suggestions on improving the message here at still much welcome.

from validator.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.