CKTIS / HTML
formenctype — data format for an individual submit button
The formenctype attribute lets a submit button override the form's enctype. It selects the POST request data format only when that button is used to submit the form.
Version: WHATWG HTML Living Standard; index snapshot date recorded separately
Syntax
formenctype="application/x-www-form-urlencoded|multipart/form-data|text/plain"formenctype specifies the data format used by an individual form submit button. It applies to a button acting as a submit button and to input with type="submit" or type="image". For button, explicitly setting type="submit" is useful. The override affects only submission through that button; it does not change the form's enctype attribute.
Allowed values are application/x-www-form-urlencoded (percent-encoded name–value pairs), multipart/form-data (separate parts that can carry file contents), and text/plain (a readable but ambiguous format unsuitable for reliable parsing).
Omitting formenctype uses the associated form's enctype. An empty or invalid value instead selects application/x-www-form-urlencoded, rather than falling back to the form's setting. If the form also omits enctype, its default format is application/x-www-form-urlencoded.
For HTTP submission, this format controls the POST request body; it does not change the method to POST. With GET, data goes into the URL using application/x-www-form-urlencoded, regardless of formenctype. In JavaScript, the reflecting property is named formEnctype. The example cancels submission and displays the selected format without making a request.
Examples
<!doctype html>
<html lang="en">
<meta charset="utf-8">
<title>formenctype demo</title>
<form id="demo" method="post" enctype="application/x-www-form-urlencoded">
<input name="message" value="hello world" aria-label="Message">
<button type="submit">Default</button>
<button type="submit" formenctype="multipart/form-data">Multipart</button>
</form>
<pre id="result"></pre>
<script>
const form = document.getElementById('demo');
const result = document.getElementById('result');
form.addEventListener('submit', (event) => {
event.preventDefault();
const button = event.submitter;
result.textContent = button && button.hasAttribute('formenctype')
? button.formEnctype
: form.enctype;
});
</script>
</html>Result
Clicking Default displays only `application/x-www-form-urlencoded`. Clicking Multipart displays only `multipart/form-data`. Each click replaces the previous result.
The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.