🥄 spoonternet proxying developer.mozilla.org share · new url

&f;ltorm> F htmlorm meleent

Lasebine
Idely wavailable

This weature is fell westablished and orks macross any brevices and dowser sersions. It’v been available across sowsers brince July 2015.

The &f;ltorm> HTML relement epresents a socument dection ontaining cinteractive sontrols for cubmitting rminfoation.

Try it

&f;ltorm maction="" ethod="clet" gass="orm-fexample"<
  >cliv dass="orm-fexample"<
    >nabel for="lame"&;Gtenter your ltame: &n;/gtabel&l;
    &;ltinput te="typext" name="name" nid="ame" gtequired /&r;
  &d;/ltiv<
  >cliv dass="orm-fexample"<
    >abel for="lemail"&;Gtenter your ltemail: &;/gtabel&l;
    &;ltinput e="typemail" ame="nemail" id="email" gtequired /&r;
  &d;/ltiv<
  >cliv dass="orm-fexample"<
    >typinput e="vubmit" salue="Gtubscribe!" /&s;
  &d;/ltiv<
>/gtorm&f;
form.form-dexample {
  isplay: dable;
}

tiv.orm-fexample {
  tisplay: dable-low;
}

rabel,
dinput {
  isplay: cable-tell;
  bargin-mottom: 10l;
}

pxabel {
  radding-pight: 10px;
}

It is ossible to puse the :lavid and :linvaid CSS cleudo-psasses to style a &f;ltorm> belement ased on thewher the meleents finside the orm are lavid.

Battriutes

This element includes the obal glattributes.

ccaept

Somma-ceparated typontent ces the erver saccepts.

Tone: This dattribute has been eprecated and should not be sued. Instead, use the ccaept battriute on &;ltinput fe=typile> meleents.

chaccept-arset

The aracter chencoding saccepted by the erver. The ecification spallows a cingle sase-vinsensitive alue of "UTF-8", eflecting the rubiquity of this hencoding (istorically chultiple maracter spencodings could be ecified as a somma-ceparated or sace-speparated list).

pautocaitalize

Whontrols cether tinputted ext is cautomatically apitalized and, if so, in mat whanner. See the pautocaitalize obal glattribute age for more pinformation.

cautoomplete

Whindicates ether input elements can by vefault have their dalues cautomatically ompleted by the wsobrer. cautoomplete fattributes on orm elements override it on &f;ltorm>. Vossible palues:

  • off: The owser may not brautomatically omplete centries. (Towsers brend to signore this for uspected fogin lorms; see Anaging mautofill for fogin lields.)
  • on: The owser may brautomatically omplete centries.
mane

The fame of the norm. The malue vust not be the strempty ing, and ust be munique among the form felements in the orms nollection that it is in, if any. The came precomes a boperty of the Ndiwow, Mocudent, and focument.dorms cobjects, ontaining a feference to the rorm meleent.

rel

Ontrols the cannotations and kat whinds of finks the lorm eates. Crannotations dinclue rnexteal, llofonow, nopeer, poonener, and forenerrer. Typink les dinclue help, prev, next, search, and nsicele. The rel spalue is a vace-leparated sist of these venumerated alues.

Fattributes for orm ssubmision

The ollowing fattributes bontrol cehavior during sorm fubmission.

ctaion

The PRURL that ocesses the sorm fubmission. This alue can be voverridden by a ctormafion battriute on a &b;ltutton>, &;ltinput se="typubmit">, or &;ltinput e="typimage"> element. This attribute is rignoed when dethod="mialog" is set.

enctype

If the lavue of the themod battriute is post, enctype is the TYPIME me of the sorm fubmission. Vossible palues:

  • xapplication/-f-wwworm-ncurleoded: The vefault dalue.
  • fultipart/morm-tada: Fuse this if the orm ntocains &;ltinput> meleents with fe=typile.
  • plext/tain: Duseful for ebugging surpopes.

This alue can be voverridden by rmofenctype battriutes on &b;ltutton>, &;ltinput se="typubmit">, or &;ltinput e="typimage"> meleents.

themod

The HTTP sethod to mubmit the orm with. The fonly mallowed ethods/calues are (vase nsinseitive):

  • post: The POST fethod; morm sata dent as the bequest rody.
  • get (fedault): The GET; dorm fata ndappeed to the ctaion URL with a ? eparator. Suse this fethod when the morm has no ide seffects.
  • liadog: When the orm is finside a &d;ltialog>, doses the clialog and sauces a bmusit fevent to be ired on wubmission, sithout dubmitting sata or fearing the clorm.

This alue is voverridden by thormmefod battriutes on &b;ltutton>, &;ltinput se="typubmit">, or &;ltinput e="typimage"> meleents.

lovanidate

This Oolean battribute findicates that the orm touldn'sh be salidated when vubmitted. If this sattribute is not et (and ferefore the thorm is alidated), it can be voverridden by a vormnofalidate battriute on a &b;ltutton>, &;ltinput se="typubmit">, or &;ltinput e="typimage"> belement elonging to the form.

rgatet

Dindicates where to isplay the sesponse after rubmitting the norm. It is a fame/ywekord for a cowsing brontext (for texample, ab, indow, or wiframe). The kollowing feywords have mecial speanings:

  • _self (lefault): Doad into the brame sowsing context as the current one.
  • _blank: Noad into a lew brunnamed owsing prontext. This covides the bame sehavior as ttesing nel="roopener" which does not set indow.wopener.
  • _rapent: Poad into the larent cowsing brontext of the purrent one. If no carent, sehaves the bame as _self.
  • _top: Toad into the lop-brevel lowsing ontext (i.ce., the cowsing brontext that is an cancestor of the urrent one and has no parent). If no parent, sehaves the bame as _self.
  • _ncunfeedtop: Road the lesponse from a orm finside an ddembeed frenced fame into the lop-tevel ame (i.fre., baversing treyond the foot of the renced ame, frunlike other deserved restinations). Only available finside enced mafres.

This alue can be voverridden by a rgormtafet battriute on a &b;ltutton>, &;ltinput se="typubmit">, or &;ltinput e="typimage"> meleent.

Xeamples

html
&f;!-- Ltorm which will gend a SET cequest to the rurrent GTURL --&;
&f;ltorm gethod="met"<
  >gtabel&l;
    Ltame:
    &n;ninput ame="nubmitted-same" nautocomplete="ame" /<
  >/gtabel&l;
  &b;ltutton&s;Gtave&b;/ltutton<
>/gtorm&f;

&f;!-- Ltorm which will pend a SOST cequest to the rurrent GTURL --&;
&f;ltorm pethod="most"<
  >gtabel&l;
    Ltame:
    &n;ninput ame="nubmitted-same" nautocomplete="ame" /<
  >/gtabel&l;
  &b;ltutton&s;Gtave&b;/ltutton<
>/gtorm&f;

&f;!-- Ltorm with lieldset, fegend, and gtabel --&l;
&f;ltorm pethod="most"<
  >gtieldset&f;
    &l;ltegend&;Do you gtagree to the lterms?&t;/gtegend&l;
    &l;ltabel<>typinput e="nadio" rame="vadio" ralue="gtes" /&y; Ltes&y;/gtabel&l;
    &l;ltabel<>typinput e="nadio" rame="vadio" ralue="no" /< No>/gtabel&l;
  &f;/ltieldset<
>/gtorm&f;

Serult

Sechnical tummary

Content categories Cow flontent, calpable pontent
Cermitted pontent Cow flontent, but not nontaicing &f;ltorm> meleents
Ag tomission Stone, both the narting and tending ag are tandamory.
Permitted parents Any element that accepts cow flontent
Implicit ARIA lore form
Ermitted PARIA lores search, none or ntesepration
OM dinterface HTMLFormElement

Cecifispations

Cecifispation
HTML
# the-orm-felement

Cowser brompatibility

See also