Hi,

The form input type number is wrong to the HTML5 W3C validation (http://validator.w3.org/nu).

I fixe this with a modification in the module:

I disable this in the file "components/number.inc":

line 292 - 294

    if ($element['#max']) {
    $element['#size'] =  strlen($element['#max']) + 1;
   }

And i changed this:

Line 238

foreach (array('id', 'name', 'value', 'size', 'min', 'max', 'step') as $property) {

by that:

foreach (array('id', 'name', 'value', 'min', 'max', 'step') as $property) {

And the HTML5 W3C validation work fine.

excuse me for my english, but i'm french.

Thanx !

Comments

Hi,

it's the same problem with input file type

Error: Attribute size not allowed on element input at this point.

<input type="file" id="edit-submitted-..." name="files[...]" size="22" class="form-file" />

I search the solution but i find this in "components/file.inc" :

    // TODO: Make managed_file respect the "size" parameter.
    /*
    $form['display']['width'] = array(
      '#type' => 'textfield',
      '#title' => t('Width'),
      '#default_value' => $component['extra']['width'],
      '#description' => t('Width of the file field.') . ' ' . t('Leaving blank will use the default size.'),
      '#size' => 5,
      '#maxlength' => 10,
      '#weight' => 4,
      '#parents' => array('extra', 'width')
    );
    */

But the attribute "size" is always here. Why ?

Edit: I changed the drupal core module file in "modules/file/file.module" and it's ok.

Line 75:

//    '#size' => 22,

The HTML5 W3C validation is now correct.

Issue summary:View changes
Priority:Major» Normal
Status:Active» Closed (works as designed)

The form input type number is wrong to the HTML5 W3C validation (http://validator.w3.org/nu).

This is true, but "size" is supported by browsers that don't support HTML5 number inputs. So it's used as the fallback when a browser doesn't support number inputs.

it's the same problem with input file type

Error: Attribute size not allowed on element input at this point.

Unfortuantely, even though "size" is not part of the HTML 4 or XHTML 1.1 spec, it's respected by browsers: http://stackoverflow.com/questions/572768/styling-an-input-type-file-button

I'm not sure if size has been added to the HTML5 spec, but since we work in the real world, an intentional setting of size is better than following a spec.

So for now, both of these issues are intentional. Setting size on both of these elements has an effect (either for backwards compatibility or for visual display).