# Bad value “X aria-required=” for attribute “maxlength” on element “input”: Expected a digit but saw “ ” instead.

> Canonical HTML version: https://rocketvalidator.com/html-validation/bad-value-x-aria-required-for-attribute-maxlength-on-element-input-expected-a-digit-but-saw-instead
> Attribution: Rocket Validator (https://rocketvalidator.com)
> License: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/)

When you write an attribute like `maxlength="200` and accidentally omit the closing quote, everything that follows — including subsequent attribute names and their values — gets absorbed into that one attribute's value. In this case, the validator sees the value of `maxlength` as `200 aria-required=` (or similar), which is not a valid integer. The parser doesn't encounter a closing `"` until it finds the next quotation mark further along in the tag, causing a cascade of errors.

This is a problem for several reasons:

- **Broken functionality**: The `maxlength` attribute won't work because `200 aria-required=` is not a valid number. The browser cannot determine the intended character limit.
- **Lost attributes**: The `aria-required` attribute is swallowed into the malformed `maxlength` value, so it never gets applied as a separate attribute. Assistive technologies like screen readers won't know the field is required.
- **Accessibility impact**: Since `aria-required="true"` is lost, users who rely on screen readers won't receive the information that the field is mandatory, potentially leading to form submission errors and a frustrating experience.

The root cause is almost always a missing closing quotation mark. Carefully check that every attribute value has both an opening and a closing `"`. This kind of typo is easy to make and easy to miss, especially in long tags with many attributes.

## Examples

### Incorrect — missing closing quote on `maxlength`

The closing `"` after `200` is missing, so the value of `maxlength` extends all the way to the next quotation mark it finds:

```html
<input type="text" name="nome" id="nome" maxlength="200 aria-required="true">
```

The validator interprets `maxlength` as having the value `200 aria-required=`, and only `true` ends up as the value of an unintended or malformed attribute. Nothing works as expected.

### Correct — properly quoted attributes

Each attribute has its own properly matched pair of quotation marks:

```html
<input type="text" name="nome" id="nome" maxlength="200" aria-required="true">
```

Here, `maxlength="200"` correctly limits the input to 200 characters, and `aria-required="true"` is a separate attribute that tells assistive technologies the field is required.

### Incorrect — missing closing quote with more attributes

This issue can happen with any combination of attributes. Here, a missing quote after `maxlength` absorbs `class` and `placeholder`:

```html
<input type="text" maxlength="50 class="username" placeholder="Enter name">
```

### Correct — all quotes properly closed

```html
<input type="text" maxlength="50" class="username" placeholder="Enter name">
```

## Tips for avoiding this issue

- **Use a code editor with syntax highlighting.** Most editors color attribute values differently from attribute names. If you see an attribute name rendered in the same color as a value string, a quote is likely missing.
- **Format attributes one per line** on complex elements. This makes it much easier to spot mismatched quotes:

```html
<input
  type="text"
  name="nome"
  id="nome"
  maxlength="200"
  aria-required="true">
```

- **Validate early and often.** Running your HTML through the W3C validator regularly helps catch these small typos before they cause confusing bugs in production.
