HTML Guides for forms
Learn how to identify and fix common HTML validation errors flagged by the W3C Validator — so your pages are standards-compliant and render correctly across every browser. Also check our Accessibility Guides.
The multiple attribute on the <select> element is a boolean attribute and does not accept a value like "1".
On a <select>, multiple lets the user pick more than one option. Like every boolean attribute in HTML, its meaning comes from whether it is present, not from what you set it to. Writing multiple="1" makes the W3C validator complain because "1" is not one of the values the spec allows.
A boolean attribute can only appear in three forms: the name on its own (multiple), an empty string (multiple=""), or the name repeated as the value (multiple="multiple"). Values such as "1", "true", or "yes" look reasonable but none of them are valid.
Invalid example
<select name="toppings" multiple="1">
<option value="cheese">Cheese</option>
<option value="mushrooms">Mushrooms</option>
<option value="olives">Olives</option>
</select>
Valid example
<select name="toppings" multiple>
<option value="cheese">Cheese</option>
<option value="mushrooms">Mushrooms</option>
<option value="olives">Olives</option>
</select>
Dropping the value and keeping just multiple is the clearest way to write it.
The autocomplete attribute holds a word that isn't one of the autofill field names defined in the HTML standard.
autocomplete tells browsers and password managers what saved data can fill a form control. Its value is either on or off on its own, or a token from a fixed list, such as name, email, tel, organization, postal-code or country. The token can be preceded by a section-* name and by shipping or billing, as in section-work shipping postal-code. The tokens are English words whatever the language of the page, and letter case doesn't matter. Browsers ignore any other value. The control then behaves as if it had no autocomplete attribute and follows its form's setting, which is on by default.
The validator reads the value word by word and quotes the first word it can't place, in lower case. So autocomplete="Choose a topic" is reported as the string "choose", and autocomplete="shipping clinic-name" as "clinic-name". on and off must stand alone: autocomplete="off email" is reported as the string "off".
If a standard token describes the control, use it. If none does, set autocomplete="off" or remove the attribute, and keep your own identifier in name or id. The usual cause depends on the element:
<input>: the field's own name ends up in the attribute, likecompany,telephoneor a word in the page's language. Look for the token that means the same thing:organizationfor a company name,telfor a phone number. The token also has to suit the input'stype, or the validator reports that it isn't allowed in this context. Invented values likenope,noneornothanksare also common, added to stop the browser from offering saved data. Writeoffinstead. On a field where the user picks a new password,new-passwordtells the browser not to fill in a saved password.<textarea>: the value is usuallymessage,commentsor a misspelling of one of them. Spelling it right doesn't help, because the list has no token for text the user writes freely. Useoffor remove the attribute. A<textarea>that collects a postal address over several lines can takestreet-address.<select>: several tokens fit a dropdown, such ascountry,bday-month,bday-year,cc-exp-monthandsex. The bad value is often text meant for people, like the field's label or its "Choose an option" prompt, sometimes copied into the attribute by a form builder. For a list the browser keeps no data for, such as topics or departments, remove the attribute.
Invalid example
<form action="/contact" method="post">
<label for="clinic">Clinic</label>
<input type="text" id="clinic" name="clinic" autocomplete="clinic-name">
<label for="topic">Topic</label>
<select id="topic" name="topic" autocomplete="Choose a topic">
<option value="">Choose a topic</option>
<option value="billing">Billing</option>
<option value="support">Support</option>
</select>
<label for="message">Message</label>
<textarea id="message" name="message" rows="6" autocomplete="message"></textarea>
<button type="submit">Send</button>
</form>
Valid example
<form action="/contact" method="post">
<label for="clinic">Clinic</label>
<input type="text" id="clinic" name="clinic" autocomplete="off">
<label for="topic">Topic</label>
<select id="topic" name="topic">
<option value="">Choose a topic</option>
<option value="billing">Billing</option>
<option value="support">Support</option>
</select>
<label for="message">Message</label>
<textarea id="message" name="message" rows="6" autocomplete="off"></textarea>
<button type="submit">Send</button>
</form>
When a standard token fits the control, use it:
<form action="/checkout" method="post">
<label for="company">Company</label>
<input type="text" id="company" name="company" autocomplete="organization">
<label for="country">Country</label>
<select id="country" name="country" autocomplete="shipping country">
<option value="ES">Spain</option>
<option value="FR">France</option>
</select>
<label for="address">Delivery address</label>
<textarea id="address" name="address" rows="3" autocomplete="shipping street-address"></textarea>
<button type="submit">Continue</button>
</form>
disabled is a boolean attribute, so on every element that accepts it you write it bare, empty or as disabled="disabled", and a value like "true" or "false" is an error.
A boolean attribute can only hold the empty string or its own name, in any letter case. So disabled, disabled="", disabled="disabled" and disabled="DISABLED" all pass. The validator reports any other value with this message and quotes what it found: "true", "false", "1", "yes", "disabled " with a trailing space, and also "disabled" with quote marks inside the value. That last one shows up as “"disabled"” and comes from markup like disabled='"disabled"' or disabled=""disabled"", usually a template that wraps an already quoted value in another pair of quotes.
Browsers don't read the value. If the attribute is there, the element is disabled, so disabled="false" disables it just as disabled="true" does. To enable the element, remove the attribute. In JavaScript, set the property (field.disabled = false) or call removeAttribute("disabled"). Calling setAttribute("disabled", "false") leaves the element disabled.
The bad value usually comes from a form builder or template that prints a boolean setting straight into the markup, often with aria-disabled="true" next to it. The validator also warns that aria-disabled is unnecessary on an element that has disabled, so remove it while you're there.
Elements that don't take disabled at all, such as <div> or <a>, get a different error: Attribute “disabled” not allowed on element “div” at this point. Remove the attribute there instead of fixing its value.
What disabled does depends on the element:
<input>,<select>,<textarea>and<button>: the control can't be focused or used, and the browser leaves its name and value out of the submitted form data. It also skips validation, so arequiredfield stops blocking the form while it's disabled. If the user shouldn't edit a field but the server still needs its value, usereadonlyon a text<input>or a<textarea>, since read-only fields are submitted.<select>has noreadonlyattribute, so send its value in a hidden<input>instead.<option>and<optgroup>: a disabled option is greyed out and can't be picked, anddisabledon an<optgroup>disables every option inside it. A common use is the placeholder at the top of a drop-down, such as "Choose a size", markeddisabled selectedso it shows first but can't be chosen again. In arequired<select>, give itvalue=""as well, so the browser treats it as a placeholder and won't submit the form until the user picks a real option.<fieldset>: disables every form control inside it, except the ones in its first<legend>. A checkbox in the legend can therefore switch the rest of the group on and off.<link>:disabledis only allowed together withrel="stylesheet", and the browser doesn't load or apply that stylesheet until the attribute is removed. It's used for alternative stylesheets, such as a high-contrast theme, that a script turns on later withlink.disabled = false.
Invalid example
<form action="/order" method="post">
<label for="size">Size</label>
<select id="size" name="size" required>
<option value="" disabled="true" selected>Choose a size</option>
<option value="s">Small</option>
<option value="m">Medium</option>
<option value="l">Large</option>
</select>
<label for="coupon">Coupon code</label>
<input type="text" id="coupon" name="coupon" disabled="false">
<fieldset id="address" disabled="disabled ">
<legend>
<label>
<input type="checkbox" id="ship-elsewhere">
Ship to a different address
</label>
</legend>
<label for="street">Street</label>
<input type="text" id="street" name="street">
</fieldset>
<button type="submit">Place order</button>
</form>
Valid example
<form action="/order" method="post">
<label for="size">Size</label>
<select id="size" name="size" required>
<option value="" disabled selected>Choose a size</option>
<option value="s">Small</option>
<option value="m">Medium</option>
<option value="l">Large</option>
</select>
<label for="coupon">Coupon code</label>
<input type="text" id="coupon" name="coupon">
<fieldset id="address" disabled>
<legend>
<label>
<input type="checkbox" id="ship-elsewhere">
Ship to a different address
</label>
</legend>
<label for="street">Street</label>
<input type="text" id="street" name="street">
</fieldset>
<button type="submit">Place order</button>
</form>
<script>
document.getElementById("ship-elsewhere").addEventListener("change", (event) => {
document.getElementById("address").disabled = !event.target.checked;
});
</script>
required is a boolean attribute, so on <input>, <select> and <textarea> you write it bare, empty or as required="required", and a value like "true" or "false" is an error.
The HTML standard allows two values for a boolean attribute: the empty string and the attribute's own name, in any letter case. So required, required="", required="required" and required="REQUIRED" all pass. The validator reports any other value with this message and quotes what it found: "true", "false", "1", "yes", and also "required " with a trailing space.
Browsers don't read the value at all. If the attribute is there, the field is mandatory, so required="false" blocks the form just like required="true" does. To make a field optional, remove the attribute.
The bad value usually comes from a form builder or template that writes a boolean setting straight into the markup, often with aria-required="true" next to it. Once you fix required, the validator warns that aria-required is unnecessary on an element that has required, so remove it too. From JavaScript, set the property (field.required = false) or call removeAttribute("required"). Calling setAttribute("required", "false") leaves the field required.
Some details depend on the element:
<input>:requiredonly applies to types a user can leave empty or unchecked:text,search,email,url,tel,password,number, the date and time types,checkbox,radioandfile. Onhidden,range,colorand the button types (submit,reset,button,image), it isn't allowed at all, and the validator says so in a separate error. Remove it there instead of fixing the value.<textarea>: a required text area blocks the form while its value is empty. The text between the opening and closing tags is the starting value, so spaces a template adds for indentation make the field count as filled in before anyone types. Put</textarea>right after the opening tag.<select>: a required drop-down (nomultiple, and nosizeabove1) needs a placeholder as its first<option>, withvalue=""and directly inside the<select>, not in an<optgroup>. An option without avalueattribute uses its text as its value, so<option>Choose a size</option>counts as an answer, and the form submits "Choose a size" if the user never opens the list. When the first option isn't a valid placeholder, the validator reports a second error about it, even whilerequiredhas a bad value.
Invalid example
<form action="/order" method="post">
<label for="email">Email</label>
<input type="email" id="email" name="email" required="true">
<label for="size">Size</label>
<select id="size" name="size" required="true">
<option value="">Choose a size</option>
<option value="s">Small</option>
<option value="m">Medium</option>
<option value="l">Large</option>
</select>
<label for="notes">Notes (optional)</label>
<textarea id="notes" name="notes" rows="3" required="false"></textarea>
<button type="submit">Place order</button>
</form>
Valid example
<form action="/order" method="post">
<label for="email">Email</label>
<input type="email" id="email" name="email" required>
<label for="size">Size</label>
<select id="size" name="size" required>
<option value="">Choose a size</option>
<option value="s">Small</option>
<option value="m">Medium</option>
<option value="l">Large</option>
</select>
<label for="notes">Notes (optional)</label>
<textarea id="notes" name="notes" rows="3"></textarea>
<button type="submit">Place order</button>
</form>
Validate at scale.
Ship accessible websites, faster.
Automated HTML & accessibility validation for large sites. Check thousands of pages against WCAG guidelines and W3C standards in minutes, not days.
1K Weekly
1,000 monthly checks. Cancel anytime.
Get 1K Weekly →Join teams across 40+ countries