HTML formmethod Attribute

Beginner
5 min read
Updated: Oct 2026
3 examples
Live preview

Definition and Usage

The formmethod attribute sets the HTTP method used when a specific submit control is activated. It overrides the form’s method for that click only. Use it on a <button> that submits a form, or on <input type="submit"> / type="image".

Common pattern: a form defaults to post for saving, while a “Search” button uses formmethod="get". The special value dialog closes an associated <dialog> without sending data to a server.

Baseline · Widely available.

Not deprecated. get and post are stable across modern browsers. The dialog value depends on <dialog> support.

GET puts data in the URL.

Do not use get (or formmethod="get") for passwords, tokens, or other secrets — they appear in the address bar and server logs.

HTML Syntax

syntax.html
<button type="submit" formmethod=" get | post | dialog">

Same attribute works on <input type="submit"> and type="image".

Attribute Values

Same keywords as the form method attribute:

ValueDescriptionTry it
getAppend form data to the action URL (query string). Good for searchTry it
postSend form data in the request body. Good for saves and secretsTry it
dialogClose the associated dialog; do not transmit form dataTry it

Live Preview

Change the override method on the second button, then submit. Submission is intercepted so you can see the effective method.

Form default method="post". The override button uses formmethod.

Demo form

formmethod="get"

HTML Examples

Short, copy-ready snippets. Use Try It Yourself for a live editor.

Example 1 — Search Button Uses get

Keep the form on post for other actions, but search with a bookmarkable GET.

HTML
<form action="/items" method="post">
  <label for="q">Query:</label>
  <input type="search" id="q" name="q">

  <button type="submit">Create item</button>
  <button type="submit" formmethod="get" formaction="/search">Search</button>
</form>
Try It Yourself

How It Works

  1. Form default. Create item uses method="post" to /items.
  2. Search overrides method. formmethod="get" puts the query in the URL.
  3. Optional URL change. formaction="/search" sends search to a different endpoint.
  4. Shareable results. GET search URLs can be bookmarked and shared.

Example 2 — Force post on One Button

Override a GET form when one action must send data in the body.

HTML
<form action="/feedback" method="get">
  <label for="msg">Message:</label>
  <textarea id="msg" name="msg"></textarea>

  <button type="submit">Preview (GET)</button>
  <button type="submit" formmethod="post">Submit (POST)</button>
</form>
Try It Yourself

How It Works

  1. Preview stays GET — data appears in the query string.
  2. Submit uses POST via formmethod="post".
  3. Body vs URL. Longer messages and sensitive text belong in POST.
  4. Same form fields for both buttons; only the method changes.

Example 3 — Close a Dialog

formmethod="dialog" closes the dialog without a network submit.

HTML
<dialog id="confirm" open>
  <form method="dialog">
    <p>Discard changes?</p>
    <button type="submit" value="cancel">Cancel</button>
    <button type="submit" value="ok" formmethod="dialog">OK</button>
  </form>
</dialog>
Try It Yourself

How It Works

  1. Form inside dialog. method="dialog" on the form is the usual pattern.
  2. formmethod="dialog" on a button does the same for that control.
  3. No HTTP request. The dialog closes; data is not posted to a URL.
  4. returnValue can come from the button’s value after close.

Edge Cases & Pitfalls

Most mistakes mix up GET privacy or forget that dialog does not submit.

privacy

GET is visible

Query strings show in history, logs, and referrers. Never put secrets on a GET submit.

dialog

dialog sends nothing

It closes the dialog only. If you need to save data, use post (or script) instead.

owner

Needs a form owner

Nest the control in a form or set the form attribute.

script

IDL name is formMethod

In JavaScript, read or set element.formMethod (camelCase).

family

Sibling overrides exist

Also see formaction, formenctype, formnovalidate, and formtarget.

Browser Support

formmethod is an HTML attribute for submit controls in the browser. It is not a Node.js, Deno, or Bun API.

✓ Baseline · Widely available

formmethod

get and post are widely available since about July 2015. The dialog value follows HTML dialog support in modern browsers.

97% Global support (approx.)
Google Chrome 9+ · dialog modern
Full support
Mozilla Firefox 4+ · dialog modern
Full support
Apple Safari 5.1+ · dialog 15.4+
Full support
Microsoft Edge 12+ · dialog modern
Full support
Opera 10.6+
Full support
Samsung Internet Modern
Full support
Internet Explorer 10+ (no dialog)
Partial
formmethod Widely supported

Bottom line: Safe to use get/post overrides everywhere modern. Treat dialog as a progressive enhancement with the dialog element.

Key Takeaways

  • Role: override the form’s method for one submit control.
  • Values: get, post, or dialog.
  • GET vs POST: search/share vs changes and secrets.
  • dialog: closes UI only — no HTTP transmission.

One line: formmethod lets each submit button choose get, post, or dialog without cloning the form.

Frequently Asked Questions

On a submit button or input type=submit (or image), formmethod sets the HTTP method for that submission. It overrides the method attribute on the owning form.
get (append data to the URL), post (send data in the request body), and dialog (close an associated dialog without transmitting form data).
Use get for safe, bookmarkable requests like search. Use post for changes, secrets, or larger payloads that should not appear in the URL.
It closes the dialog that contains (or is associated with) the form and does not send the form data to a server.
method is set on the form and is the default. formmethod is set on a specific submit control and overrides method when that control is used.
get and post are Baseline widely available. The dialog value is supported in modern browsers that support the HTML dialog element.

Next: formnovalidate

Skip constraint validation when a specific submit button is used.

formnovalidate tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

8 people found this page helpful