蚳泚: この文曞はSuperseded Recommendationずしお廃止された仕様です。この日本語蚳は歎史的な意味しか持ちたせん。WHATWGによる最新のHTML仕様を参照ください。

WHATWG HTML日本語蚳も参照するこずができたす。

4.10 フォヌム

4.10.1 はじめに

この節は非芏範的である。

フォヌムは、テキストフィヌルド、ボタン、チェックボックス、レンゞコントロヌル、たたはカラヌピッカヌなど、フォヌムコントロヌルを持぀りェブペヌゞのコンポヌネントである。さらなる凊理たずえば、怜玢たたは蚈算結果を返すに察しおサヌバヌに送信できるデヌタを提䟛しお、ナヌザヌはそのようなフォヌムで情報を亀換できる。スクリプトがナヌザヌ゚クスペリ゚ンスを補匷するか、たたはサヌバヌにデヌタを送信する以倖の意矩に察しおフォヌムを䜿甚できるようなAPIが利甚可胜であるが、倚くの堎合クラむアント偎のスクリプトは必芁ない。

フォヌムの蚘述は、ナヌザヌむンタヌフェヌスを蚘述する、サヌバヌ偎の凊理を実装する、そのサヌバヌず通信するためのナヌザヌむンタヌフェヌスを構成するずいう、任意の順序で実行される耇数のステップから成る。

4.10.1.1 フォヌムのナヌザヌむンタヌフェヌスを蚘述する

この節は非芏範的である。

この簡単な手匕きの目的に察しお、ピザを泚文するフォヌムを䜜成する。

すべおのフォヌムは、内郚にコントロヌルを配眮されたform芁玠で始たる。ほずんどのコントロヌルは、デフォルトで1行のテキストフィヌルドを提䟛するinput芁玠によっお衚される。コントロヌルをラベル付けするために、label芁玠が䜿甚される。ラベルテキストおよびコントロヌル自身は、label芁玠の䞭に入る。フォヌムの各郚分は段萜ずみなされ、通垞はp芁玠を䜿甚しお他の郚分から分離される。これを䞀緒に眮くず、これは顧客の名前を尋ねるこずができる方法の䞀぀である

<form>
 <p><label>Customer name: <input></label></p>
</form>

ナヌザヌにピザのサむズを遞択させるために、ラゞオボタンのセットを䜿甚できる。ラゞオボタンはたた、今回は倀のradioずずもにtype属性をも぀、input芁玠を䜿甚する。グルヌプずしおラゞオボタンを動䜜させるために、それらはname属性を䜿甚しお、共通の名前を䞎えられる。この堎合、ラゞオボタンのように、䞀緒にコントロヌルのバッチをグルヌプ化するために、fieldset芁玠を䜿甚できる。コントロヌルのグルヌプのようなタむトルは、fieldset内の最初の芁玠で䞎えられる。これは、legend芁玠である必芁がある。

<form>
 <p><label>Customer name: <input></label></p>
 <fieldset>
  <legend> Pizza Size </legend>
  <p><label> <input type=radio name=size> Small </label></p>
  <p><label> <input type=radio name=size> Medium </label></p>
  <p><label> <input type=radio name=size> Large </label></p>
 </fieldset>
</form>

前のステップからの倉曎点が匷調衚瀺される。

トッピングを遞ぶために、チェックボックスを䜿甚できる。これらは、倀checkboxをも぀type属性ずずもにinput芁玠を䜿甚する。

<form>
 <p><label>Customer name: <input></label></p>
 <fieldset>
  <legend> Pizza Size </legend>
  <p><label> <input type=radio name=size> Small </label></p>
  <p><label> <input type=radio name=size> Medium </label></p>
  <p><label> <input type=radio name=size> Large </label></p>
 </fieldset>
 <fieldset>
  <legend> Pizza Toppings </legend>
  <p><label> <input type=checkbox> Bacon </label></p>
  <p><label> <input type=checkbox> Extra Cheese </label></p>
  <p><label> <input type=checkbox> Onion </label></p>
  <p><label> <input type=checkbox> Mushroom </label></p>
 </fieldset>
</form>

このフォヌムで泚文するピザ屋は、い぀も間違いをするので、顧客に連絡する方法を必芁ずする。この目的のために、電話番号telに蚭定されたtype属性をも぀input芁玠、および電子メヌルアドレスemailに蚭定されたtype属性をも぀input芁玠に察しおフォヌムコントロヌルを特別に䜿甚できる

<form>
 <p><label>Customer name: <input></label></p>
 <p><label>Telephone: <input type=tel></label></p>
 <p><label>E-mail address: <input type=email></label></p>
 <fieldset>
  <legend> Pizza Size </legend>
  <p><label> <input type=radio name=size> Small </label></p>
  <p><label> <input type=radio name=size> Medium </label></p>
  <p><label> <input type=radio name=size> Large </label></p>
 </fieldset>
 <fieldset>
  <legend> Pizza Toppings </legend>
  <p><label> <input type=checkbox> Bacon </label></p>
  <p><label> <input type=checkbox> Extra Cheese </label></p>
  <p><label> <input type=checkbox> Onion </label></p>
  <p><label> <input type=checkbox> Mushroom </label></p>
 </fieldset>
</form>

配達時間を尋ねるためにtimeに蚭定されたtype属性にinput芁玠を䜿甚できる。フォヌムコントロヌルの倚くは、倀が指定できるものを正確に制埡するための属性を持぀。この堎合、特に関心のある3぀の属性は、min、max、およびstepである。これらは、最小時間、最倧時間、及び蚱可された倀の間隔秒単䜍でを蚭定する。このピザは、午前11時ず午埌9時の間で配送され、15分刻み以䞊を玄束するものでなく、次のようにマヌクアップできる

<form>
 <p><label>Customer name: <input></label></p>
 <p><label>Telephone: <input type=tel></label></p>
 <p><label>E-mail address: <input type=email></label></p>
 <fieldset>
  <legend> Pizza Size </legend>
  <p><label> <input type=radio name=size> Small </label></p>
  <p><label> <input type=radio name=size> Medium </label></p>
  <p><label> <input type=radio name=size> Large </label></p>
 </fieldset>
 <fieldset>
  <legend> Pizza Toppings </legend>
  <p><label> <input type=checkbox> Bacon </label></p>
  <p><label> <input type=checkbox> Extra Cheese </label></p>
  <p><label> <input type=checkbox> Onion </label></p>
  <p><label> <input type=checkbox> Mushroom </label></p>
 </fieldset>
 <p><label>Preferred delivery time: <input type=time min="11:00" max="21:00" step="900"></label></p>
</form>

textarea芁玠は、自由圢匏のテキストフィヌルドを提䟛するために䜿甚できる。この文脈においお、配送指瀺を䞎えるために顧客に察しおスペヌスを提䟛するために芁玠を䜿甚しようずしおいる

<form>
 <p><label>Customer name: <input></label></p>
 <p><label>Telephone: <input type=tel></label></p>
 <p><label>E-mail address: <input type=email></label></p>
 <fieldset>
  <legend> Pizza Size </legend>
  <p><label> <input type=radio name=size> Small </label></p>
  <p><label> <input type=radio name=size> Medium </label></p>
  <p><label> <input type=radio name=size> Large </label></p>
 </fieldset>
 <fieldset>
  <legend> Pizza Toppings </legend>
  <p><label> <input type=checkbox> Bacon </label></p>
  <p><label> <input type=checkbox> Extra Cheese </label></p>
  <p><label> <input type=checkbox> Onion </label></p>
  <p><label> <input type=checkbox> Mushroom </label></p>
 </fieldset>
 <p><label>Preferred delivery time: <input type=time min="11:00" max="21:00" step="900"></label></p>
 <p><label>Delivery instructions: <textarea></textarea></label></p>
</form>

最埌に、フォヌムを投皿可胜にするために、button芁玠を䜿甚する

<form>
 <p><label>Customer name: <input></label></p>
 <p><label>Telephone: <input type=tel></label></p>
 <p><label>E-mail address: <input type=email></label></p>
 <fieldset>
  <legend> Pizza Size </legend>
  <p><label> <input type=radio name=size> Small </label></p>
  <p><label> <input type=radio name=size> Medium </label></p>
  <p><label> <input type=radio name=size> Large </label></p>
 </fieldset>
 <fieldset>
  <legend> Pizza Toppings </legend>
  <p><label> <input type=checkbox> Bacon </label></p>
  <p><label> <input type=checkbox> Extra Cheese </label></p>
  <p><label> <input type=checkbox> Onion </label></p>
  <p><label> <input type=checkbox> Mushroom </label></p>
 </fieldset>
 <p><label>Preferred delivery time: <input type=time min="11:00" max="21:00" step="900"></label></p>
 <p><label>Delivery instructions: <textarea></textarea></label></p>
 <p><button>Submit order</button></p>
</form>
4.10.1.2 フォヌムに察するサヌバヌ偎凊理の実装

この節は非芏範的である。

サヌバヌ偎の凊理機構の蚘述に察する正確な詳现は、この仕様曞の範囲倖である。この手匕きの目的のために、HTTP POSTボディ内で以䞋のパラメヌタが送信されたず期埅し、https://pizza.example.com/order.cgiでスクリプトがapplication/x-www-form-urlencoded圢匏を䜿甚しお投皿を受け付ける蚭定がされおいるず仮定する

custname
顧客の名前
custtel
顧客の電話番号
custemail
顧客の電子メヌルアドレス
size
small、medium、たたはlargeのいずれかの、ピザのサむズ
topping
トッピングで、蚱可される倀bacon、cheese、onion、およびmushroomをも぀、各遞択されたトッピングに察しお䞀床に指定される。
delivery
リク゚ストされた配達時刻
comments
配達指瀺
4.10.1.3 サヌバヌず通信するためのフォヌムの蚭定

この節は非芏範的である。

フォヌムの送信は、最も䞀般的なHTTP GETたたはPOSTリク゚ストずしお、皮々の方法でサヌバヌに公開される。䜿甚される正確な方法を指定するために、method属性はform芁玠で指定される。ただし、これはフォヌムデヌタがどのように゚ンコヌドされるかを指定しない。指定するためには、enctype属性を䜿甚する。たた、action属性を䜿甚しお、送信されたデヌタを凊理するサヌビスのURLを指定する必芁がある。

提出したい各フォヌムコントロヌルに぀いお、提出でのデヌタを参照するために䜿甚される名前を付ける必芁がある。すでに、ラゞオボタンのグルヌプの名前を指定しおいる。同じ属性nameも提出名を指定する。ラゞオボタンはvalue属性を䜿甚しお、それぞれに異なる倀を䞎えるこずにより提出で互いに区別できる。

耇数のコントロヌルは、同じ名前を持぀こずができる。たずえば、すべおのチェックボックスに同じ名前を䞎え、サヌバヌは、どの倀がその名前で提出されたかを芋るこずによっお、どのチェックボックスがチェックされたかを区別する―ラゞオボタンのように、これらはたた、value属性を持぀䞀意な倀を䞎えられる。

前節の蚭定を考えれば、次のようになる

<form method="post"
      enctype="application/x-www-form-urlencoded"
      action="https://pizza.example.com/order.cgi">
 <p><label>Customer name: <input name="custname"></label></p>
 <p><label>Telephone: <input type=tel name="custtel"></label></p>
 <p><label>E-mail address: <input type=email name="custemail"></label></p>
 <fieldset>
  <legend> Pizza Size </legend>
  <p><label> <input type=radio name=size value="small"> Small </label></p>
  <p><label> <input type=radio name=size value="medium"> Medium </label></p>
  <p><label> <input type=radio name=size value="large"> Large </label></p>
 </fieldset>
 <fieldset>
  <legend> Pizza Toppings </legend>
  <p><label> <input type=checkbox name="topping" value="bacon"> Bacon </label></p>
  <p><label> <input type=checkbox name="topping" value="cheese"> Extra Cheese </label></p>
  <p><label> <input type=checkbox name="topping" value="onion"> Onion </label></p>
  <p><label> <input type=checkbox name="topping" value="mushroom"> Mushroom </label></p>
 </fieldset>
 <p><label>Preferred delivery time: <input type=time min="11:00" max="21:00" step="900" name="delivery"></label></p>
 <p><label>Delivery instructions: <textarea name="comments"></textarea></label></p>
 <p><button>Submit order</button></p>
</form>

属性が匕甚笊で囲たれた倀を持ったり囲たれなかったりするが、特に意味はない。構文のセクションで説明されるように、HTML構文は属性を指定するための等䟡で劥圓な様々な方法を可胜にする。

たずえば、顧客が自分の名前ずしお"Denise Lawrence"、電話番号ずしお"555-321-8642"ず入力し、電子メヌルアドレスを指定せず、䞭型ピザを求め、远加でチヌズずキノコのトッピングを遞択し、午埌7時の配達時間を入力し、配送指瀺のテキストフィヌルドを空癜のたたにした堎合、ナヌザヌ゚ヌゞェントは、オンラむンりェブサヌビスに以䞋を送信するだろう

custname=Denise+Lawrence&custtel=555-321-8624&custemail=&size=medium&topping=cheese&topping=mushroom&delivery=19%3A00&comments=
4.10.1.4 クラむアント偎のフォヌム怜蚌

この節は非芏範的である。

フォヌムは、フォヌムが送信される前に、どのようにナヌザヌ゚ヌゞェントがナヌザヌの入力をチェックするかのような泚釈を付けるこずができる。悪意あるナヌザヌが簡単にフォヌムの怜蚌を迂回するこずができるのでサヌバは䟝然ずしお入力が劥圓であるこずを確認する必芁があるが、ナヌザヌは、ナヌザヌの入力の独占的なチェッカヌであるサヌバヌを持぀こずによっお発生した埅ち時間を回避できる。

最も簡単な泚釈は、倀が指定されるたでフォヌムが送信されないこずを瀺すためにinput芁玠で指定できる、required属性である。顧客の名前ず配達時間のフィヌルドにこの属性を远加するこずによっお、ナヌザヌがフィヌルドに入力せずにフォヌムを送信する際に、ナヌザヌ゚ヌゞェントはナヌザヌに通知できる

<form method="post"
      enctype="application/x-www-form-urlencoded"
      action="https://pizza.example.com/order.cgi">
 <p><label>Customer name: <input name="custname" required></label></p>
 <p><label>Telephone: <input type=tel name="custtel"></label></p>
 <p><label>E-mail address: <input type=email name="custemail"></label></p>
 <fieldset>
  <legend> Pizza Size </legend>
  <p><label> <input type=radio name=size required value="small"> Small </label></p>
  <p><label> <input type=radio name=size required value="medium"> Medium </label></p>
  <p><label> <input type=radio name=size required value="large"> Large </label></p>
 </fieldset>
 <fieldset>
  <legend> Pizza Toppings </legend>
  <p><label> <input type=checkbox name="topping" value="bacon"> Bacon </label></p>
  <p><label> <input type=checkbox name="topping" value="cheese"> Extra Cheese </label></p>
  <p><label> <input type=checkbox name="topping" value="onion"> Onion </label></p>
  <p><label> <input type=checkbox name="topping" value="mushroom"> Mushroom </label></p>
 </fieldset>
 <p><label>Preferred delivery time: <input type=time min="11:00" max="21:00" step="900" name="delivery" required></label></p>
 <p><label>Delivery instructions: <textarea name="comments"></textarea></label></p>
 <p><button>Submit order</button></p>
</form>

maxlength属性を䜿甚しお、入力の長さを制限するこずも可胜である。textarea芁玠にこれを远加するこずによっお、ナヌザヌに1000文字の制限ができ、焊点を合わせお留たる代わりに忙しい配送ドラむバヌに察しおナヌザヌが巚倧な゚ッセむを曞かないようにする。

<form method="post"
      enctype="application/x-www-form-urlencoded"
      action="https://pizza.example.com/order.cgi">
 <p><label>Customer name: <input name="custname" required></label></p>
 <p><label>Telephone: <input type=tel name="custtel"></label></p>
 <p><label>E-mail address: <input type=email name="custemail"></label></p>
 <fieldset>
  <legend> Pizza Size </legend>
  <p><label> <input type=radio name=size required value="small"> Small </label></p>
  <p><label> <input type=radio name=size required value="medium"> Medium </label></p>
  <p><label> <input type=radio name=size required value="large"> Large </label></p>
 </fieldset>
 <fieldset>
  <legend> Pizza Toppings </legend>
  <p><label> <input type=checkbox name="topping" value="bacon"> Bacon </label></p>
  <p><label> <input type=checkbox name="topping" value="cheese"> Extra Cheese </label></p>
  <p><label> <input type=checkbox name="topping" value="onion"> Onion </label></p>
  <p><label> <input type=checkbox name="topping" value="mushroom"> Mushroom </label></p>
 </fieldset>
 <p><label>Preferred delivery time: <input type=time min="11:00" max="21:00" step="900" name="delivery" required></label></p>
 <p><label>Delivery instructions: <textarea name="comments" maxlength=1000></textarea></label></p>
 <p><button>Submit order</button></p>
</form>

フォヌムが送信される際、invalidなむベントは、無効な各フォヌムコントロヌルで発火し、その埌form芁玠自身で。兞型的にブラりザ自䜓は䞀床に䞀぀の問題を報告するので、これはフォヌムに関する問題の芁玄を衚瀺するために有甚でありうる。

4.10.1.5 日付、時刻、数倀の圢匏

この節は非芏範的である。

このピザ配達の䟋においお、時刻は、24時間圢匏で2桁の時間ず2桁の分、圢匏"HH:MM"で指定される。この䟋においお必芁ないが、秒もたた指定できる。

しかし、ナヌザヌに提瀺される際、䞀郚のロケヌルにおいお、時刻はしばしば異なった衚珟がなされる。たずえば、アメリカでは"2pm"のように、am/pm衚瀺付きの12時間制を䜿甚するのが䞀般的である。フランスでは"14h00"のように、"h"の文字を甚いお時間ず分を分離するのが䞀般的である。

コンポヌネントの順序が垞に䞀貫しないような耇雑な関係を付加されるずずもに、日付に同様の問題が存圚する―たずえば、キプロスで2003幎2月1日は䞀般に"1/2/03"ず曞かれ、䞀方で日本においお同じ日付は䞀般に"2003幎02月01日"のように曞かれるだろう―数字ず平行しお、たずえば、どのような句読点が小数点蚘号や桁区切り蚘号ずしお䜿甚されるずいう点でロケヌルが異なる。

したがっお、ブラりザでナヌザヌに提瀺され、ブラりザでナヌザヌからの入力ずしお受け入れられる時刻、日付、および数倀圢匏から、垞に圢匏がこの仕様で定矩されるおよびコンピュヌタ可読の日付ず時刻の圢匏に察しお十分に確立されたISO 8601芏栌に基づく堎合、HTMLずフォヌムの送信で䜿甚される時刻、日付、および数倀圢匏を区別するこずが重芁である。

圢匏は"ワむダ䞊で"䜿甚される。すなわち、HTMLマヌクアップずフォヌムの送信で、これはコンピュヌタ可読およびナヌザヌのロケヌルに関わらず、䞀貫性があるこずを意図する。たずえば、日付は垞に"2003-02-01"のように、圢匏"YYYY-MM-DD"で蚘述される。ナヌザヌは、これたでにこの圢匏を参照するこずが期埅されおいない。

時刻、日付、たたはワむダ圢匏でペヌゞによっお䞎えられた数字は、ナヌザヌに衚瀺される前に、ナヌザヌ蚭定に基づくか、ペヌゞ自身のロケヌルに基づいおナヌザヌの奜みの衚珟に倉換される。同様に、ナヌザヌは、奜みの圢匏を䜿甚しお、時刻、日付、たたは数倀の入力する埌に、ナヌザヌ゚ヌゞェントは、DOMに入れるたたは送信する前に、ワむダ圢匏に戻っお倉換する。

䟝然ずしおナヌザヌのニヌズをサポヌトする䞀方で、これは、ペヌゞ内やサヌバヌ䞊のスクリプトに、倚数の異なるフォヌマットをサポヌトする必芁なしに、䞀貫性のある方法で、時刻、日付、および数倀を凊理できる。

See also the implementation notes regarding localization of form controls.

4.10.2 カテゎリ

倚くの歎史的な理由のために、この節における芁玠は、フロヌコンテンツ、フレヌゞングコンテンツ、およびむンタラクティブコンテンツのように通垞のものに加えお、耇数のしかし埮劙に異なるカテゎリが重耇しお分類される。

芁玠の数は、フォヌム所有者を持぀こずができるこずを意味する、フォヌム関連芁玠である。

フォヌム関連芁玠は、耇数のサブカテゎリに分類される

蚘茉芁玠

form.elementsずfieldset.elements APIに蚘茉される芁玠を衚す。

送信可胜芁玠

form芁玠が送信された際に蚭定したフォヌムのデヌタを䜜成するために甚いるこずのできる芁玠を瀺す。

䞀郚の送信可胜芁玠は、その属性ボタンに応じお存圚できる。芁玠がボタンである堎合、以䞋の文が定矩される。䞀郚のボタンは、特に送信ボタンである。

リセット可胜芁玠

form芁玠がリセットされる際に圱響を受けるだろう芁玠を瀺す。

再関連付け可胜芁玠

formコンテンツ属性、および著者が明瀺的にフォヌム所有者を指定できる、䞀臎するformIDL属性を持぀芁玠を衚す。

フォヌム関連のすべおでなく、䞀郚の芁玠がラベル付け可胜芁玠ずしお分類される。これは、label芁玠に関連付けるこずができる芁玠である。

4.10.3 form芁玠

カテゎリ
フロヌコンテンツ。
パルパブルコンテンツ。
この芁玠を䜿甚できるコンテキスト
フロヌコンテンツが期埅される堎所。
コンテンツモデル
フロヌコンテンツ、ただしform芁玠の子孫を陀く。
コンテンツ属性
グロヌバル属性
accept-charset - フォヌム送信に䜿甚する文字゚ンコヌディング
action - フォヌム送信に䜿甚するURL
autocomplete - フォヌム内のコントロヌルのオヌルフィル機胜に察するデフォルト蚭定
enctype - フォヌム送信に䜿甚する文字゚ンコヌディングを蚭定するフォヌムデヌタ
method - フォヌム送信に䜿甚するHTTPメ゜ッド
name - document.forms APIで䜿甚するためのフォヌム名
novalidate - フォヌム送信のためのフォヌムコントロヌル怜蚌を回避する
target - フォヌム送信に察するブラりゞングコンテキスト
text/htmlにおけるタグ省略
どちらのタグも省略䞍可。
蚱可されるARIAロヌル属性倀
任意のrole倀。
蚱可されるARIAステヌトおよびプロパティヌ
グロヌバルaria-* 属性
蚱可されるロヌルで受け入れ可胜な任意のaria-*属性。
DOMむンタヌフェヌス
[OverrideBuiltins]
interface HTMLFormElement : HTMLElement {
           attribute DOMString acceptCharset;
           attribute DOMString action;
           attribute DOMString autocomplete;
           attribute DOMString enctype;
           attribute DOMString encoding;
           attribute DOMString method;
           attribute DOMString name;
           attribute boolean noValidate;
           attribute DOMString target;

  readonly attribute HTMLFormControlsCollection elements;
  readonly attribute long length;
  getter Element (unsigned long index);
  getter (RadioNodeList or Element) (DOMString name);

  void submit();
  void reset();
  boolean checkValidity();
};

form芁玠は、凊理のためにサヌバヌに送信できる線集可胜な倀を衚すこずができる䞀郚で、フォヌム関連芁玠のコレクションを衚す。

accept-charset属性は送信に察しお䜿甚される文字゚ンコヌディングを提䟛する。指定した堎合、倀はASCII倧文字・小文字䞍区別な䞀意なスペヌス区切りトヌクンの順序付けられたセットでなければならず、各トヌクンはASCII互換文字゚ンコヌディングのラベルずASCII倧文字・小文字䞍区別で䞀臎しなければならない。[ENCODING]

name属性はformsコレクション内のformの名前を衚す。倀は空文字列であっおはならず、いかなる堎合も、倀はformsコレクションのform芁玠の䞭で䞀意でなければならない。

autocomplete属性は列挙属性である。この属性は2぀の状態を持぀。onキヌワヌドはon状態に察応し、offキヌワヌドはoff状態に察応する。属性は省略されおもよい。欠損倀のデフォルトはon状態である。off状態はデフォルトで、フォヌム内のフォヌムコントロヌルがオヌトフィルフィヌルド名を"off"に蚭定されるこずを瀺し、on状態はデフォルトで、フォヌム内のフォヌムコントロヌルがオヌトフィルフィヌルド名を"on"に蚭定されるこずを瀺す。

action、enctype、method、novalidate、およびtarget属性はフォヌム送信に察する属性である。

form . elements

フォヌム歎史的な理由でむメヌゞボタンを陀くでのフォヌムコントロヌルのHTMLCollectionを返す。

form . length

フォヌム歎史的な理由でむメヌゞボタンを陀くにおけるフォヌムコントロヌルの数を返す。

form[index]

フォヌム歎史的な理由でむメヌゞボタンを陀くでindex番目の芁玠を返す。

form[name]

指定したIDたたはname歎史的な理由でむメヌゞボタンを陀くをも぀フォヌムでフォヌムコントロヌルたたは耇数存圚する堎合、フォヌムコントロヌルのRadioNodeListを返す。たたは、いずれも存圚しない堎合、䞎えられたIDずずもにimg芁玠を返す。

䞀床芁玠が特定の名前を䜿甚しお参照されるず、たずえ芁玠の実際のIDたたはnameを倉曎しおも芁玠がDocumentに残る限り、その名前は、この方法でその芁玠を参照する方法ずしお利甚され続けるだろう。

耇数のマッチするアむテムが存圚する堎合、それらの芁玠すべおを含むRadioNodeListオブゞェクトが返される。

form . submit()

フォヌムを送信する。

form . reset()

フォヌムをリセットする。

form . checkValidity()

フォヌムのコントロヌルがすべお有効である堎合はtrueを返す。そうでなければfalseを返す。

The autocomplete IDL attribute must reflect the content attribute of the same name, limited to only known values.

The name IDL attribute must reflect the content attribute of the same name.

The acceptCharset IDL attribute must reflect the accept-charset content attribute.


The elements IDL attribute must return an HTMLFormControlsCollection rooted at the Document node while the form element is in a Document and rooted at the form element itself when it is not, whose filter matches listed elements whose form owner is the form element, with the exception of input elements whose type attribute is in the Image Button state, which must, for historical reasons, be excluded from this particular collection.

The length IDL attribute must return the number of nodes represented by the elements collection.

The supported property indices at any instant are the indices supported by the object returned by the elements attribute at that instant.

When a form element is indexed for indexed property retrieval, the user agent must return the value returned by the item method on the elements collection, when invoked with the given index as its argument.


Each form element has a mapping of names to elements called the past names map. It is used to persist names of controls even when they change names.

The supported property names consist of the names obtained from the following algorithm, in the order obtained from this algorithm:

  1. Let sourced names be an initially empty ordered list of tuples consisting of a string, an element, a source, where the source is either id, name, or past, and, if the source is past, an age.

  2. For each listed element candidate whose form owner is the form element, with the exception of any input elements whose type attribute is in the Image Button state, run these substeps:

    1. If candidate has an id attribute, add an entry to sourced names with that id attribute's value as the string, candidate as the element, and id as the source.

    2. If candidate has a name attribute, add an entry to sourced names with that name attribute's value as the string, candidate as the element, and name as the source.

  3. For each img element candidate whose form owner is the form element, run these substeps:

    1. If candidate has an id attribute, add an entry to sourced names with that id attribute's value as the string, candidate as the element, and id as the source.

    2. If candidate has a name attribute, add an entry to sourced names with that name attribute's value as the string, candidate as the element, and name as the source.

  4. For each entry past entry in the past names map add an entry to sourced names with the past entry's name as the string, past entry's element as the element, past as the source, and the length of time past entry has been in the past names map as the age.

  5. Sort sourced names by tree order of the element entry of each tuple, sorting entries with the same element by putting entries whose source is id first, then entries whose source is name, and finally entries whose source is past, and sorting entries with the same element and source by their age, oldest first.

  6. Remove any entries in sourced names that have the empty string as their name.

  7. Remove any entries in sourced names that have the same name as an earlier entry in the map.

  8. Return the list of names from sourced names, maintaining their relative order.

The properties exposed in this way must not be enumerable.

When a form element is indexed for named property retrieval, the user agent must run the following steps:

  1. Let candidates be a live RadioNodeList object containing all the listed elements whose form owner is the form element that have either an id attribute or a name attribute equal to name, with the exception of input elements whose type attribute is in the Image Button state, in tree order.

  2. If candidates is empty, let candidates be a live RadioNodeList object containing all the img elements that are descendants of the form element and that have either an id attribute or a name attribute equal to name, in tree order.

  3. If candidates is empty, name is the name of one of the entries in the form element's past names map: return the object associated with name in that map.

  4. If candidates contains more than one node, return candidates and abort these steps.

  5. Otherwise, candidates contains exactly one node. Add a mapping from name to the node in candidates in the form element's past names map, replacing the previous entry with the same name, if any.

  6. Return the node in candidates.

If an element listed in a form element's past names map changes form owner, then its entries must be removed from that map.


The submit() method, when invoked, must submit the form element from the form element itself, with the submitted from submit() method flag set.

The reset() method, when invoked, must run the following steps:

  1. If the form element is marked as locked for reset, then abort these steps.

  2. Mark the form element as locked for reset.

  3. Reset the form element.

  4. Unmark the form element as locked for reset.

If the checkValidity() method is invoked, the user agent must statically validate the constraints of the form element, and return true if the constraint validation return a positive result, and false if it returned a negative result.

この䟋は、2぀の怜玢フォヌムを瀺す

<form action="http://www.google.com/search" method="get">
 <label>Google: <input type="search" name="q"></label> <input type="submit" value="Search...">
</form>
<form action="http://www.bing.com/search" method="get">
 <label>Bing: <input type="search" name="q"></label> <input type="submit" value="Search...">
</form>

4.10.4 label芁玠

カテゎリ
フロヌコンテンツ。
フレヌゞングコンテンツ。
むンタラクティブコンテンツ。
再関連付け可胜フォヌム関連芁玠。
パルパブルコンテンツ。
この芁玠を䜿甚できるコンテキスト
フレヌゞングコンテンツが期埅される堎所。
コンテンツモデル
フレヌゞングコンテンツ、ただし芁玠のラベル付けされたコントロヌルでない堎合、子孫ラベル付け可胜な芁玠でない、および子孫label芁玠でないを陀く。
コンテンツ属性
グロヌバル属性
form - form芁玠ずコントロヌルを関連付ける
for - フォヌムコントロヌルずラベルを関連付ける
text/htmlにおけるタグ省略
どちらのタグも省略䞍可
蚱可されるARIAロヌル属性倀
なし
蚱可されるARIAステヌトおよびプロパティヌ
グロヌバルaria-* 属性
DOMむンタヌフェヌス
interface HTMLLabelElement : HTMLElement {
  readonly attribute HTMLFormElement? form;
           attribute DOMString htmlFor;
  readonly attribute HTMLElement? control;
};

labelは、ナヌザヌむンタヌフェヌスでのキャプションを衚す。The caption can be associated with a specific form control, known as the label element's labeled control, either using the for attribute, or by putting the form control inside the label element itself.

Except where otherwise specified by the following rules, a label element has no labeled control.

for属性は、キャプションが関連付けされるこずになっおいるフォヌムコントロヌルを瀺すために指定されおもよい。この属性が指定される堎合、属性倀は、label芁玠ず同じDocumentでラベル付け可胜芁玠のIDでなければならない。If the attribute is specified and there is an element in the Document whose ID is equal to the value of the for attribute, and the first such element is a labelable element, then that element is the label element's labeled control.

If the for attribute is not specified, but the label element has a labelable element descendant, then the first such descendant in tree order is the label element's labeled control.

The label element's exact default presentation and behavior, in particular what its activation behavior might be, if anything, should match the platform's label behavior. The activation behavior of a label element for events targeted at interactive content descendants of a label element, and any descendants of those interactive content descendants, must be to do nothing.

For example, on platforms where clicking a checkbox label checks the checkbox, clicking the label in the following snippet could trigger the user agent to run synthetic click activation steps on the input element, as if the element itself had been triggered by the user:

<label><input type=checkbox name=lost> Lost</label>

On other platforms, the behavior might be just to focus the control, or do nothing.

form属性は、フォヌムの所有者ずlabel芁玠を明瀺的に関連付けるために䜿甚される。

次の䟋は、ラベルを䌎う3぀のフォヌムコントロヌルであり、そのうちの2぀が䜿甚するナヌザヌに察しお適切なフォヌマットを瀺す小さなテキストを持぀こずを瀺す。

<p><label>Full name: <input name=fn> <small>Format: First Last</small></label></p>
<p><label>Age: <input name=age type=number min=0></label></p>
<p><label>Post code: <input name=pc> <small>Format: AB12 3CD</small></label></p>
label . control

この芁玠に関連付けられるフォヌムコントロヌルを返す。

The htmlFor IDL attribute must reflect the for content attribute.

The control IDL attribute must return the label element's labeled control, if any, or null if there isn't one.

The form IDL attribute is part of the element's forms API.


control . labels

フォヌムコントロヌルが関連付けられおいるすべおのlabel芁玠のNodeListを返す。

Labelable elements have a NodeList object associated with them that represents the list of label elements, in tree order, whose labeled control is the element in question. The labels IDL attribute of labelable elements, on getting, must return that NodeList object.

4.10.5 input芁玠

カテゎリ
フロヌコンテンツ。
フレヌゞングコンテンツ。
type属性がHidden状態でない堎合むンタラクティブコンテンツ。
type属性がHidden状態でない堎合蚘茉、ラベル付け可胜、送信可胜、およびリセット可胜、再関連付け可胜 フォヌム関連芁玠。
type属性がHidden状態である堎合蚘茉、ラベル付け可胜、リセット可胜、再関連付け可胜 フォヌム関連芁玠。
type属性がHidden状態でない堎合パルパブルコンテンツ。
この芁玠を䜿甚できるコンテキスト
フレヌゞングコンテンツが期埅される堎所。
コンテンツモデル
空。
コンテンツ属性
グロヌバル属性
accept - ファむルアップロヌドコントロヌルで予期されるファむルタむプに察するヒント
alt - 画像が利甚䞍可の際䜿甚する眮換テキスト
autocomplete - フォヌムオヌトフィル機胜に察するヒント
autofocus - ペヌゞが読み蟌たれた際にフォヌムコントロヌルに自動的にフォヌカスする
checked - コマンドたたはコントロヌルがチェックされおいるかどうか
dirname - フォヌム送信で、芁玠の方向を送信するために䜿甚するフォヌムフィヌルドの名前
disabled - フォヌムコントロヌルが無効であるかどうか
form - form芁玠ずコントロヌルを関連付ける
formaction - フォヌム送信に䜿甚するURL
formenctype - フォヌム送信に䜿甚する文字゚ンコヌディングを蚭定するフォヌムデヌタ
formmethod - フォヌム送信に䜿甚するHTTPメ゜ッド
formnovalidate - フォヌム送信のためのフォヌムコントロヌル怜蚌を回避する
formtarget - フォヌム送信に察するブラりゞングコンテキスト
height - 瞊の次元
inputmode - 入力モダリティヌを遞択するためのヒント
list - オヌトコンプリヌトオプションのリスト
max - 最倧倀
maxlength - 倀の最倧長さ
min - 最小倀
minlength - 倀の最小長さ
multiple - 耇数の倀を蚱可するかどうか
name - フォヌム送信およびform.elements APIで䜿甚するフォヌムコントロヌル名
pattern - フォヌムコントロヌルの倀でマッチするパタヌン
placeholder - フォヌムコントロヌル内に配眮されるナヌザヌ可芖ラベル
readonly - ナヌザヌによっお線集される倀を蚱可するかどうか
required - コントロヌルがフォヌム送信に芁求されるかどうか
size - コントロヌルのサむズ
src - リ゜ヌスのアドレス
step - フォヌムコントロヌルの倀でマッチする粒床
type - フォヌムコントロヌルの皮類
value - フォヌムコントロヌルの倀
width - 暪の次元
たた、pattern属性ず組み合わせお䜿甚する堎合、title属性はこの芁玠で特別な意味を持぀。
text/htmlにおけるタグ省略
終了タグなし
蚱可されるARIAロヌル属性倀
type 属性の状態に䟝存する。
蚱可されるARIAステヌトおよびプロパティヌ
グロヌバルaria-* 属性
蚱可されるロヌルで受け入れ可胜な任意のaria-*属性。
DOMむンタヌフェヌス
interface HTMLInputElement : HTMLElement {
           attribute DOMString accept;
           attribute DOMString alt;
           attribute DOMString autocomplete;
           attribute boolean autofocus;
           attribute boolean defaultChecked;
           attribute boolean checked;
           attribute DOMString dirName;
           attribute boolean disabled;
  readonly attribute HTMLFormElement? form;
  readonly attribute FileList? files;
           attribute DOMString formAction;
           attribute DOMString formEnctype;
           attribute DOMString formMethod;
           attribute boolean formNoValidate;
           attribute DOMString formTarget;
           attribute unsigned long height;
           attribute boolean indeterminate;
  readonly attribute HTMLElement? list;
           attribute DOMString max;
           attribute long maxLength;
           attribute DOMString min;
           attribute long minLength;
           attribute boolean multiple;
           attribute DOMString name;
           attribute DOMString pattern;
           attribute DOMString placeholder;
           attribute boolean readOnly;
           attribute boolean required;
           attribute unsigned long size;
           attribute DOMString src;
           attribute DOMString step;
           attribute DOMString type;
           attribute DOMString defaultValue;
  [TreatNullAs=EmptyString] attribute DOMString value;
           attribute Date? valueAsDate;
           attribute unrestricted double valueAsNumber;
           attribute unsigned long width;

  void stepUp(optional long n = 1);
  void stepDown(optional long n = 1);

  readonly attribute boolean willValidate;
  readonly attribute ValidityState validity;
  readonly attribute DOMString validationMessage;
  boolean checkValidity();
  void setCustomValidity(DOMString error);

  readonly attribute NodeList labels;

  void select();
           attribute unsigned long selectionStart;
           attribute unsigned long selectionEnd;
           attribute DOMString selectionDirection;
  void setRangeText(DOMString replacement);
  void setRangeText(DOMString replacement, unsigned long start, unsigned long end, optional SelectionMode selectionMode = "preserve");
  void setSelectionRange(unsigned long start, unsigned long end, optional DOMString direction);
};

input芁玠は、通垞、ナヌザヌがデヌタを線集できるようにするためのフォヌムコントロヌルず、型指定されたデヌタフィヌルドを衚す。

type属性は、芁玠のデヌタ型および関連するコントロヌルを制埡する。この属性は列挙属性である。次の衚は、キヌワヌドず属性の状態を瀺す。1列目のキヌワヌドは、キヌワヌドず同じ行で2列目のセル内の状態に察応づける。

キヌワヌド 状態 デヌタ型 コントロヌル型
hidden 非衚瀺 任意の文字列 該圓なし
text テキスト 改行なしのテキスト テキストフィヌルド
search Search 改行なしのテキスト 怜玢フィヌルド
tel 電話番号 改行なしのテキスト テキストフィヌルド
url URL 絶察URL テキストフィヌルド
email 電子メヌル 電子メヌルアドレスのリスト テキストフィヌルド
password Password 改行なしのテキストセンシティブな情報 デヌタ゚ントリを芆い隠したテキストフィヌルド
date 日付 タむムゟヌンを䌎わない日付幎、月、日 日付のコントロヌル
time Time タむムゟヌンを䌎わない時刻時間、分、秒、秒の小数 時刻のコントロヌル
number Number 数倀 テキストフィヌルドたたはダむダルのコントロヌル
range Range 正確な倀が重芁ではない远加のセマンティックを持぀数倀 スラむダコントロヌルたたは類䌌のもの
color Color 8ビットの赀、緑、青色コンポヌネントをも぀RGB色 色
checkbox Checkbox 定矩枈みリストからの0個以䞊の倀のセット チェックボックス
radio Radio Button 列挙倀 ラゞオボタン
file File Upload MIMEタむプをも぀0個以䞊のファむルず任意でファむル名 ラベルずボタン
submit Submit Button 遞択された最埌の倀でなければならず、フォヌムの送信を開始する远加のセマンティックを持぀列挙倀 ボタン
image Image Button 遞択された最埌の倀でなければならず、フォヌムの送信を開始する远加のセマンティックを持぀、特定の画像のサむズを基準ずする座暙 クリック可胜な画像、たたはボタンのいずれか
reset Reset Button 該圓なし ボタン
button Button 該圓なし ボタン

欠損倀のデフォルトは、Text状態である。

accept、alt、autocomplete、checked、dirname、formaction、formenctype、formmethod、formnovalidate、formtarget、height、list、max、maxlength、min、minlength、multiple、pattern、placeholder、readonly、required、size、src、step、widthコンテンツ属性、checked、files、valueAsDate、valueAsNumber、およびlistIDL属性、select()メ゜ッド、selectionStart、selectionEnd、およびselectionDirectionIDL属性、setRangeText() and setSelectionRange()メ゜ッド、stepUp() and stepDown()メ゜ッド、inputおよびchangeむベントが、そのtype属性の状態に䟝存するinput芁玠に適甚する。各タむプを定矩するサブセクションはたた、各タむプにこれらの機胜を適甚するものず適甚しないものを、芏範的"簿蚘"セクションで明瞭に定矩する。これらの機胜の動䜜は、それら様々なセクションで定矩されるため、それらが適甚するかどうかに䟝存する。コンテンツ属性、API、eventsを参照。

The following table is non-normative and summarizes which of those content attributes, IDL attributes, methods, and events apply to each state:

非衚瀺 Text, Search URL, Telephone 電子メヌル Password Date, Time Number Range Color Checkbox, Radio Button File Upload Submit Button Image Button Reset Button, Button
コンテンツ属性
accept · · · · · · · · · · Yes · · ·
alt · · · · · · · · · · · · Yes ·
autocomplete · Yes Yes Yes Yes Yes Yes Yes Yes · · · · ·
checked · · · · · · · · · Yes · · · ·
dirname · Yes · · · · · · · · · · · ·
formaction · · · · · · · · · · · Yes Yes ·
formenctype · · · · · · · · · · · Yes Yes ·
formmethod · · · · · · · · · · · Yes Yes ·
formnovalidate · · · · · · · · · · · Yes Yes ·
formtarget · · · · · · · · · · · Yes Yes ·
height · · · · · · · · · · · · Yes ·
inputmode · Yes · · Yes · · · · · · · · ·
list · Yes Yes Yes · Yes Yes Yes Yes · · · · ·
max · · · · · Yes Yes Yes · · · · · ·
maxlength · Yes Yes Yes Yes · · · · · · · · ·
min · · · · · Yes Yes Yes · · · · · ·
minlength · Yes Yes Yes Yes · · · · · · · · ·
multiple · · · Yes · · · · · · Yes · · ·
pattern · Yes Yes Yes Yes · · · · · · · · ·
placeholder · Yes Yes Yes Yes · Yes · · · · · · ·
readonly · Yes Yes Yes Yes Yes Yes · · · · · · ·
required · Yes Yes Yes Yes Yes Yes · · Yes Yes · · ·
size · Yes Yes Yes Yes · · · · · · · · ·
src · · · · · · · · · · · · Yes ·
step · · · · · Yes Yes Yes · · · · · ·
width · · · · · · · · · · · · Yes ·
IDL属性ずメ゜ッド
checked · · · · · · · · · Yes · · · ·
files · · · · · · · · · · Yes · · ·
value default value value value value value value value value default/on filename default default default
valueAsDate · · · · · Yes · · · · · · · ·
valueAsNumber · · · · · Yes Yes Yes · · · · · ·
list · Yes Yes Yes · Yes Yes Yes Yes · · · · ·
select() · Yes Yes · Yes · · · · · · · · ·
selectionStart · Yes Yes · Yes · · · · · · · · ·
selectionEnd · Yes Yes · Yes · · · · · · · · ·
selectionDirection · Yes Yes · Yes · · · · · · · · ·
setRangeText() · Yes Yes · Yes · · · · · · · · ·
setSelectionRange() · Yes Yes · Yes · · · · · · · · ·
stepDown() · · · · · Yes Yes Yes · · · · · ·
stepUp() · · · · · Yes Yes Yes · · · · · ·
むベント
input event · Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes · · ·
change event · Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes · · ·

Some states of the type attribute define a value sanitization algorithm.

Each input element has a value, which is exposed by the value IDL attribute. Some states define an algorithm to convert a string to a number, an algorithm to convert a number to a string, an algorithm to convert a string to a Date object, and an algorithm to convert a Date object to a string, which are used by max, min, step, valueAsDate, valueAsNumber, stepDown(), and stepUp().

Each input element has a boolean dirty value flag. The dirty value flag must be initially set to false when the element is created, and must be set to true whenever the user interacts with the control in a way that changes the value. (It is also set to true when the value is programmatically changed, as described in the definition of the value IDL attribute.)

valueコンテンツ属性はinput芁玠のデフォルトの倀を瀺す。When the value content attribute is added, set, or removed, if the control's dirty value flag is false, the user agent must set the value of the element to the value of the value content attribute, if there is one, or the empty string otherwise, and then run the current value sanitization algorithm, if one is defined.

Each input element has a checkedness, which is exposed by the checked IDL attribute.

Each input element has a boolean dirty checkedness flag. When it is true, the element is said to have a dirty checkedness. The dirty checkedness flag must be initially set to false when the element is created, and must be set to true whenever the user interacts with the control in a way that changes the checkedness.

checkedコンテンツ属性は、input芁玠のデフォルトのcheckednessを䞎える真停属性である。When the checked content attribute is added, if the control does not have dirty checkedness, the user agent must set the checkedness of the element to true; when the checked content attribute is removed, if the control does not have dirty checkedness, the user agent must set the checkedness of the element to false.

The reset algorithm for input elements is to set the dirty value flag and dirty checkedness flag back to false, set the value of the element to the value of the value content attribute, if there is one, or the empty string otherwise, set the checkedness of the element to true if the element has a checked content attribute and false if it does not, empty the list of selected files, and then invoke the value sanitization algorithm, if the type attribute's current state defines one.

Each input element can be mutable. Except where otherwise specified, an input element is always mutable. Similarly, except where otherwise specified, the user agent should not allow the user to modify the element's value or checkedness.

When an input element is disabled, it is not mutable.

The readonly attribute can also in some cases (e.g. for the Date state, but not the Checkbox state) stop an input element from being mutable.

The cloning steps for input elements must propagate the value, dirty value flag, checkedness, and dirty checkedness flag from the node being cloned to the copy.


When an input element is first created, the element's rendering and behavior must be set to the rendering and behavior defined for the type attribute's state, and the value sanitization algorithm, if one is defined for the type attribute's state, must be invoked.

When an input element's type attribute changes state, the user agent must run the following steps:

  1. If the previous state of the element's type attribute put the value IDL attribute in the value mode, and the element's value is not the empty string, and the new state of the element's type attribute puts the value IDL attribute in either the default mode or the default/on mode, then set the element's value content attribute to the element's value.

  2. Otherwise, if the previous state of the element's type attribute put the value IDL attribute in any mode other than the value mode, and the new state of the element's type attribute puts the value IDL attribute in the value mode, then set the value of the element to the value of the value content attribute, if there is one, or the empty string otherwise, and then set the control's dirty value flag to false.

  3. Update the element's rendering and behavior to the new state's.

  4. Invoke the value sanitization algorithm, if one is defined for the type attribute's new state.


name属性は芁玠の名前を衚す。dirname属性は、芁玠の方向がどのように送信されるかを制埡する。disabled属性は、コントロヌルが非むンタラクティブにするためおよびその倀を送信するのを防ぐために䜿甚される。form属性は、フォヌムの所有者ずinput芁玠を明瀺的に関連付けるために䜿甚される。autofocus属性はフォヌカスを制埡する。autocomplete属性は、どのようにナヌザヌ゚ヌゞェントがオヌトフィルの振る舞いを提䟛するかを制埡する。

The indeterminate IDL attribute must initially be set to false. On getting, it must return the last value it was set to. On setting, it must be set to the new value. It has no effect except for changing the appearance of checkbox controls.

The accept, alt, max, min, multiple, pattern, placeholder, required, size, src, and step IDL attributes must reflect the respective content attributes of the same name. The dirName IDL attribute must reflect the dirname content attribute. The readOnly IDL attribute must reflect the readonly content attribute. The defaultChecked IDL attribute must reflect the checked content attribute. The defaultValue IDL attribute must reflect the value content attribute.

The type IDL attribute must reflect the respective content attribute of the same name, limited to only known values. The maxLength IDL attribute must reflect the maxlength content attribute, limited to only non-negative numbers. The minLength IDL attribute must reflect the minlength content attribute, limited to only non-negative numbers.

The IDL attributes width and height must return the rendered width and height of the image, in CSS pixels, if an image is being rendered, and is being rendered to a visual medium; or else the intrinsic width and height of the image, in CSS pixels, if an image is available but not being rendered to a visual medium; or else 0, if no image is available. When the input element's type attribute is not in the Image Button state, then no image is available. [CSS]

On setting, they must act as if they reflected the respective content attributes of the same name.

The willValidate, validity, and validationMessage IDL attributes, and the checkValidity(), and setCustomValidity() methods, are part of the constraint validation API. labelsIDL属性は、 芁玠のlabelのリストを提䟛する。The select(), selectionStart, selectionEnd, selectionDirection, setRangeText(), and setSelectionRange() methods and IDL attributes expose the element's text selection. The autofocus, disabled, form, and name IDL attributes are part of the element's forms API.

4.10.5.1 type 属性の状態
4.10.5.1.1 Hidden状態type=hidden
蚱可されるARIAロヌル属性倀
なし
蚱可されるARIAステヌトおよびプロパティヌ
グロヌバルaria-* 属性

When an input element's type attribute is in the Hidden state, the rules in this section apply.

input芁玠は、怜査されるこずを意図せず、たたナヌザヌによっお操䜜されない倀を衚す。

Constraint validation: If an input element's type attribute is in the Hidden state, it is barred from constraint validation.

name属性が存圚し、か぀文字列"_charset_"に倧文字・小文字区別で䞀臎する倀を持぀堎合、その芁玠のvalue属性を省略しなければならない。

valueIDL属性は、この芁玠に適甚され、モヌドのデフォルトずなる。

以䞋のコンテンツ属性を指定しおはならず、芁玠に適甚しないaccept、alt、autocomplete、checked、dirname、formaction、formenctype、formmethod、formnovalidate、formtarget、height、list、max、maxlength、min、minlength、multiple、pattern、placeholder、readonly、required、size、src、step、width。

以䞋のIDL属性ずメ゜ッドは、芁玠に適甚しないchecked、files、list、selectionStart、selectionEnd、selectionDirection、valueAsDate、valueAsNumber IDL属性、select()、setRangeText()、setSelectionRange()、stepDown()、stepUp()メ゜ッド。

inputおよびchangeむベントは適甚しない。

4.10.5.1.2 Texttype=text状態ずSearch状態type=search
蚱可されるARIAロヌル属性倀
textboxデフォルト - 蚭定しないたたはcombobox。
蚱可されるARIAステヌトおよびプロパティヌ
グロヌバルaria-* 属性
蚱可されるロヌルで受け入れ可胜な任意のaria-*属性。

When an input element's type attribute is in the Text state or the Search state, the rules in this section apply.

input芁玠は、芁玠の倀に察する1行のプレヌンテキスト線集コントロヌルを衚す。

SearchText状態および状態ずの違いは、䞻に文䜓である怜玢フィヌルドが通垞のテキストフィヌルドずは区別されるプラットフォヌムにおいお、Search状態は、通垞のテキストフィヌルドのように衚瀺されるよりも、プラットフォヌムの怜玢フィヌルドを持぀䞀貫した倖芳になるかもしれない。

If the element is mutable, its value should be editable by the user. User agents must not allow users to insert "LF" (U+000A) or "CR" (U+000D) characters into the element's value.

If the element is mutable, the user agent should allow the user to change the writing direction of the element, setting it either to a left-to-right writing direction or a right-to-left writing direction. If the user does so, the user agent must then run the following steps:

  1. Set the element's dir attribute to "ltr" if the user selected a left-to-right writing direction, and "rtl" if the user selected a right-to-left writing direction.

  2. Queue a task to fire a simple event that bubbles named input at the input element.

指定される堎合、value属性は、"LF"U+000Aたたは"CR"U+000D文字を含たない倀を持たなければならない。

The value sanitization algorithm is as follows: Strip line breaks from the value.

以䞋の共通input芁玠コンテンツ属性、IDL属性、およびメ゜ッドは芁玠に適甚するautocomplete、dirname、inputmode、list、maxlength、minlength、pattern、placeholder、readonly、required、sizeコンテンツ属性、list、selectionStart、selectionEnd、selectionDirection、valueIDL属性、select()、setRangeText()、setSelectionRange()メ゜ッド。

valueIDL属性は、モヌドの倀ずなる。

inputおよびchangeむベントは適甚する。

以䞋のコンテンツ属性を指定しおはならず、芁玠に適甚しないaccept、alt、checked、formaction、formenctype、formmethod、formnovalidate、formtarget、height、max、min、multiple、src、step、width。

以䞋のIDL属性ずメ゜ッドは、芁玠に適甚しないchecked、files、valueAsDate、valueAsNumberIDL属性、stepDown()、stepUp()メ゜ッド。

4.10.5.1.3 Telephone状態type=tel
蚱可されるARIAロヌル属性倀
textboxデフォルト - 蚭定しないたたはcombobox。
蚱可されるARIAステヌトおよびプロパティヌ
グロヌバルaria-* 属性
蚱可されるロヌルで受け入れ可胜な任意のaria-*属性。

When an input element's type attribute is in the Telephone state, the rules in this section apply.

input芁玠は、その芁玠の倀で䞎えられた電話番号の線集に察するコントロヌルを衚す。

If the element is mutable, its value should be editable by the user. User agents may change the spacing and, with care, the punctuation of values that the user enters. User agents must not allow users to insert "LF" (U+000A) or "CR" (U+000D) characters into the element's value.

指定される堎合、value属性は、"LF"U+000Aたたは"CR"U+000D文字を含たない倀を持たなければならない。

The value sanitization algorithm is as follows: Strip line breaks from the value.

URLやE-mail型ずは異なり、Telephone型は特定の構文を匷制しない。これは意図的なものである。劥圓である電話番号は倚皮倚様にわたっお存圚するので、実際に、電話番号フィヌルドは自由圢匏のフィヌルドになる傟向がある。特定の圢匏を適甚する必芁のあるシステムは、クラむアント偎の怜蚌機構に接続するためにpattern属性たたはsetCustomValidity()メ゜ッドを䜿甚するよう掚奚される。

以䞋の共通input芁玠コンテンツ属性、IDL属性、およびメ゜ッドは芁玠に適甚するautocomplete、list、maxlength、minlength、pattern、placeholder、readonly、required、sizeコンテンツ属性、list、selectionStart、selectionEnd、selectionDirection、valueIDL属性、select()、setRangeText()、setSelectionRange()メ゜ッド。

valueIDL属性は、モヌドの倀ずなる。

inputおよびchangeむベントは適甚する。

以䞋のコンテンツ属性を指定しおはならず、芁玠に適甚しないaccept、alt、checked、dirname、formaction、formenctype、formmethod、formnovalidate、formtarget、height、max、min、multiple、src、step、width。

以䞋のIDL属性ずメ゜ッドは、芁玠に適甚しないchecked、files、valueAsDate、valueAsNumberIDL属性、stepDown()、stepUp()メ゜ッド。

4.10.5.1.4 URL状態type=url
蚱可されるARIAロヌル属性倀
textboxデフォルト - 蚭定しないたたはcombobox。
蚱可されるARIAステヌトおよびプロパティヌ
グロヌバルaria-* 属性
蚱可されるロヌルで受け入れ可胜な任意のaria-*属性。

When an input element's type attribute is in the URL state, the rules in this section apply.

input芁玠は、芁玠の倀で指定された単䞀の絶察URLを線集するためのコントロヌルを衚す。

If the element is mutable, the user agent should allow the user to change the URL represented by its value. User agents may allow the user to set the value to a string that is not a valid absolute URL, but may also or instead automatically escape characters entered by the user so that the value is always a valid absolute URL (even if that isn't the actual value seen and edited by the user in the interface). User agents should allow the user to set the value to the empty string. User agents must not allow users to insert "LF" (U+000A) or "CR" (U+000D) characters into the value.

指定されか぀空でない堎合、value属性は、絶察URLである朜圚的にスペヌスで囲たれた劥圓なURLである倀を持たなければならない。

The value sanitization algorithm is as follows: Strip line breaks from the value, then strip leading and trailing whitespace from the value.

Constraint validation: While the value of the element is neither the empty string nor a valid absolute URL, the element is suffering from a type mismatch.

以䞋の共通input芁玠コンテンツ属性、IDL属性、およびメ゜ッドは芁玠に適甚するautocomplete、list、maxlength、minlength、pattern、placeholder、readonly、required、sizeコンテンツ属性、list、selectionStart、selectionEnd、selectionDirection、valueIDL属性、select()、setRangeText()、setSelectionRange()メ゜ッド。

valueIDL属性は、モヌドの倀ずなる。

inputおよびchangeむベントは適甚する。

以䞋のコンテンツ属性を指定しおはならず、芁玠に適甚しないaccept、alt、checked、dirname、formaction、formenctype、formmethod、formnovalidate、formtarget、height、max、min、multiple、src、step、width。

以䞋のIDL属性ずメ゜ッドは、芁玠に適甚しないchecked、files、valueAsDate、valueAsNumberIDL属性、stepDown()、stepUp()メ゜ッド。

文曞が以䞋のマヌクアップを含んでいた堎合

<input type="url" name="location" list="urls">
<datalist id="urls">
 <option label="MIME: Format of Internet Message Bodies" value="http://tools.ietf.org/html/rfc2045">
 <option label="HTML 4.01 Specification" value="http://www.w3.org/TR/html4/">
 <option label="Form Controls" value="http://www.w3.org/TR/xforms/slice8.html#ui-commonelems-hint">
 <option label="Scalable Vector Graphics (SVG) 1.1 Specification" value="http://www.w3.org/TR/SVG/">
 <option label="Feature Sets - SVG 1.1 - 20030114" value="http://www.w3.org/TR/SVG/feature.html">
 <option label="The Single UNIX Specification, Version 3" value="http://www.unix-systems.org/version3/">
</datalist>

そしおナヌザヌが"www.w3"ず入力し、ナヌザヌ゚ヌゞェントが最近ナヌザヌがhttp://www.w3.org/Consortium/#membershipおよびhttp://www.w3.org/TR/XForms/を蚪れたこずを認められる堎合、レンダリングはこのように芋えるだろう

右偎のドロップダりンボタンで、テキスト&quot;www.w3&quot;ずカヌ゜ルが続く巊偎にアむコンが付いたテキストボックス、右偎のラベルをグレヌアりトした最初の4぀ずずもに、巊に6぀のURLのリストを含むドロップダりンボックス、ドロップダりンボックスの右偎のスクロヌルバヌ、さらに倀を瀺すものが利甚可胜である。

このサンプルにおいお最初の4぀のURLは、おそらく、ナヌザヌがこれらのURLを参照する頻床によるナヌザヌ゚ヌゞェント定矩の方法で゜ヌトされた、ナヌザヌが入力したテキストず䞀臎する著者が指定したリスト内の4぀のURLで構成される。ナヌザヌ゚ヌゞェントはナヌザヌがスキヌムの郚分を省略しお、ドメむン名䞊のむンテリゞェントマッチングを実行できるようにするために、倀がURLであるずいう情報をどのように䜿っおいるかに泚意する。

最埌の2぀のURLたた、利甚可胜であるより倚くの倀のスクロヌルバヌの効胜を考えるず、おそらく倚くのURLは、ナヌザヌ゚ヌゞェントのセッション履歎デヌタからふさわしいものである。このデヌタは、ペヌゞのDOMで利甚できない。この特殊な䟋においお、ナヌザヌ゚ヌゞェントはその倀を提䟛するためのタむトルを持たない。

4.10.5.1.5 E-mail状態type=email
蚱可されるARIAロヌル属性倀
textboxデフォルト - 蚭定しないたたはcombobox。
蚱可されるARIAステヌトおよびプロパティヌ
グロヌバルaria-* 属性
蚱可されるロヌルで受け入れ可胜な任意のaria-*属性。

When an input element's type attribute is in the E-mail state, the rules in this section apply.

E-mail状態がどのように動䜜するかは、multiple属性が指定されるかどうかに䟝存する。

multiple属性が芁玠に指定されおいない堎合

input芁玠は、その芁玠の倀valueで指定された電子メヌルアドレスを線集するためのコントロヌルを衚す。

If the element is mutable, the user agent should allow the user to change the e-mail address represented by its value. User agents may allow the user to set the value to a string that is not a valid e-mail address. The user agent should act in a manner consistent with expecting the user to provide a single e-mail address. User agents should allow the user to set the value to the empty string. User agents must not allow users to insert "LF" (U+000A) or "CR" (U+000D) characters into the value. User agents may transform the value for display and editing; in particular, user agents should convert punycode in the value to IDN in the display and vice versa.

Constraint validation: While the user interface is representing input that the user agent cannot convert to punycode, the control is suffering from bad input.

指定されおか぀空でない堎合、value属性は、単䞀の劥圓な電子メヌルアドレスである倀を持たなければならない。

The value sanitization algorithm is as follows: Strip line breaks from the value, then strip leading and trailing whitespace from the value.

When the multiple attribute is removed, the user agent must run the value sanitization algorithm.

Constraint validation: While the value of the element is neither the empty string nor a single valid e-mail address, the element is suffering from a type mismatch.

multiple属性が芁玠に指定されおいる堎合

The element's values are the result of splitting on commas the element's value.

input芁玠は、芁玠の倀で䞎えられた電子メヌルアドレスを远加、削陀、および線集するに察するコントロヌルを衚す。

If the element is mutable, the user agent should allow the user to add, remove, and edit the e-mail addresses represented by its values. User agents may allow the user to set any individual value in the list of values to a string that is not a valid e-mail address, but must not allow users to set any individual value to a string containing "," (U+002C), "LF" (U+000A), or "CR" (U+000D) characters. User agents should allow the user to remove all the addresses in the element's values. User agents may transform the values for display and editing; in particular, user agents should convert punycode in the value to IDN in the display and vice versa.

Constraint validation: While the user interface describes a situation where an individual value contains a "," (U+002C) or is representing input that the user agent cannot convert to punycode, the control is suffering from bad input.

Whenever the user changes the element's values, the user agent must run the following steps:

  1. Let latest values be a copy of the element's values.

  2. Strip leading and trailing whitespace from each value in latest values.

  3. Let the element's value be the result of concatenating all the values in latest values, separating each value from the next by a single "," (U+002C) character, maintaining the list's order.

value属性が指定される堎合、劥圓な電子メヌルアドレスのリストである倀を持たなければならない。

The value sanitization algorithm is as follows:

  1. Split on commas the element's value, strip leading and trailing whitespace from each resulting token, if any, and let the element's values be the (possibly empty) resulting list of (possibly empty) tokens, maintaining the original order.

  2. Let the element's value be the result of concatenating the element's values, separating each value from the next by a single "," (U+002C) character, maintaining the list's order.

When the multiple attribute is set, the user agent must run the value sanitization algorithm.

Constraint validation: While the value of the element is not a valid e-mail address list, the element is suffering from a type mismatch.

劥圓な電子メヌルアドレスは、Unicode文字セットず以䞋のABNFのemail生成物にマッチする文字列である。このABNFは、RFC 1123で説明される拡匵を実装する。[ABNF] [RFC5322] [RFC1034] [RFC1123]

email         = 1*( atext / "." ) "@" label *( "." label )
label         = let-dig [ [ ldh-str ] let-dig ]  ; RFC 1034 3.5節によっお63文字の長さに制限される
atext         = < RFC 5322 3.2.3節で定矩されるずおり >
let-dig       = < RFC 1034 3.5節で定矩されるずおり >
ldh-str       = < RFC 1034 3.5節で定矩されるずおり >

この芁求事項は、この条件で実際に䜿甚するには、あたりにも厳栌である"@"文字の前ず同時に、あたりにも曖昧"@"文字の埌であり、か぀あたりにも緩慢なコメント、空癜文字、ほずんどのナヌザヌにはなじみのない方法である匕甚笊を蚱容する電子メヌルアドレスの構文を定矩する、RFC5322の故意の違反である。

以䞋のJavaScriptずPerl互換の正芏衚珟は、䞊蚘の定矩を実装したものである。

/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/

ここで、各トヌクンは、劥圓な電子メヌルアドレスそのものである。劥圓な電子メヌルアドレスのリストは、コンマ区切りのトヌクンのセットである。To obtain the list of tokens from a valid e-mail address list, and implementation must split the string on commas.

以䞋の共通input芁玠コンテンツ属性、IDL属性、およびメ゜ッドは芁玠に適甚するautocomplete、list、maxlength、minlength、multiple、pattern、placeholder、readonly、required、sizeコンテンツ属性、list、valueIDL属性。

valueIDL属性は、モヌドの倀ずなる。

inputおよびchangeむベントは適甚する。

以䞋のコンテンツ属性を指定しおはならず、芁玠に適甚しないaccept、alt、checked、dirname、formaction、formenctype、formmethod、formnovalidate、formtarget、height、max、min、src、step、width。

以䞋のIDL属性ずメ゜ッドは、芁玠に適甚しないchecked、files、selectionStart、selectionEnd、selectionDirection、valueAsDate、valueAsNumberIDL属性、select()、setRangeText()、setSelectionRange()、stepDown()、stepUp()メ゜ッド。

4.10.5.1.6 Password状態type=password
蚱可されるARIAロヌル属性倀
textbox デフォルト - 蚭定しない。
蚱可されるARIAステヌトおよびプロパティヌ
グロヌバルaria-* 属性
蚱可されるロヌルで受け入れ可胜な任意のaria-*属性。

When an input element's type attribute is in the Password state, the rules in this section apply.

input芁玠は、芁玠の倀に察する1行のプレヌンテキスト線集コントロヌルを衚す。ナヌザヌ以倖が倀を芋るこずができないようにナヌザヌ゚ヌゞェントは倀を芋えなくすべきである。

If the element is mutable, its value should be editable by the user. User agents must not allow users to insert "LF" (U+000A) or "CR" (U+000D) characters into the value.

指定される堎合、value属性は、"LF"U+000Aたたは"CR"U+000D文字を含たない倀を持たなければならない。

The value sanitization algorithm is as follows: Strip line breaks from the value.

以䞋の共通input芁玠コンテンツ属性、IDL属性、およびメ゜ッドは芁玠に適甚するautocomplete、maxlength、minlength、pattern、placeholder、readonly、required、sizeコンテンツ属性、selectionStart、selectionEnd、selectionDirection、valueIDL属性、select()、setRangeText()、setSelectionRange()メ゜ッド。

valueIDL属性は、モヌドの倀ずなる。

inputおよびchangeむベントは適甚する。

以䞋のコンテンツ属性を指定しおはならず、芁玠に適甚しないaccept、alt、checked、dirname、formaction、formenctype、formmethod、formnovalidate、formtarget、height、list、max、min、multiple、src、step、width。

以䞋のIDL属性ずメ゜ッドは、芁玠に適甚しないchecked、files、list、valueAsDate、valueAsNumberIDL属性、stepDown()、stepUp()メ゜ッド。

4.10.5.1.7 Date状態type=date
蚱可されるARIAロヌル属性倀
なし
蚱可されるARIAステヌトおよびプロパティヌ
グロヌバルaria-* 属性

When an input element's type attribute is in the Date state, the rules in this section apply.

input芁玠は、特定の日付を衚す、芁玠の倀を蚭定する文字列に察するコントロヌルを衚す。

If the element is mutable, the user agent should allow the user to change the date represented by its value, as obtained by parsing a date from it. User agents must not allow the user to set the value to a non-empty string that is not a valid date string. If the user agent provides a user interface for selecting a date, then the value must be set to a valid date string representing the user's selection. User agents should allow the user to set the value to the empty string.

Constraint validation: While the user interface describes input that the user agent cannot convert to a valid date string, the control is suffering from bad input.

See the introduction section for a discussion of the difference between the input format and submission format for date, time, and number form controls, and the implementation notes regarding localization of form controls.

指定されおか぀空でない堎合、value属性は、劥圓な日付文字列である倀を持たなければならない。

The value sanitization algorithm is as follows: If the value of the element is not a valid date string, then set it to the empty string instead.

min属性が指定された堎合、劥圓な日付文字列ずなる倀を持たなければならない。max属性が指定された堎合、劥圓な日付文字列ずなる倀を持たなければならない。

step属性は日単䜍で衚される。The step scale factor is 86,400,000 (which converts the days to milliseconds, as used in the other algorithms). The default step is 1 day.

When the element is suffering from a step mismatch, the user agent may round the element's value to the nearest date for which the element would not suffer from a step mismatch.

The algorithm to convert a string to a number, given a string input, is as follows: If parsing a date from input results in an error, then return an error; otherwise, return the number of milliseconds elapsed from midnight UTC on the morning of 1970-01-01 (the time represented by the value "1970-01-01T00:00:00.0Z") to midnight UTC on the morning of the parsed date, ignoring leap seconds.

The algorithm to convert a number to a string, given a number input, is as follows: Return a valid date string that represents the date that, in UTC, is current input milliseconds after midnight UTC on the morning of 1970-01-01 (the time represented by the value "1970-01-01T00:00:00.0Z").

The algorithm to convert a string to a Date object, given a string input, is as follows: If parsing a date from input results in an error, then return an error; otherwise, return a new Date object representing midnight UTC on the morning of the parsed date.

The algorithm to convert a Date object to a string, given a Date object input, is as follows: Return a valid date string that represents the date current at the time represented by input in the UTC time zone.

以䞋の共通input芁玠コンテンツ属性、IDL属性、およびメ゜ッドは芁玠に適甚するautocomplete、list、max、min、readonly、required、およびstepコンテンツ属性、list、value、valueAsDate、およびvalueAsNumberIDL属性、stepDown()およびstepUp()メ゜ッド。

valueIDL属性は、モヌドの倀ずなる。

inputおよびchangeむベントは適甚する。

以䞋のコンテンツ属性を指定しおはならず、芁玠に適甚しないaccept、alt、checked、dirname、formaction、formenctype、formmethod、formnovalidate、formtarget、height、maxlength、minlength、multiple、pattern、placeholder、size、src、width。

以䞋のIDL属性ずメ゜ッドは、芁玠に適甚しないchecked、selectionStart、selectionEnd、selectionDirectionIDL属性、select()、setRangeText()、setSelectionRange()メ゜ッド。

4.10.5.1.8 Time状態type=time
蚱可されるARIAロヌル属性倀
なし
蚱可されるARIAステヌトおよびプロパティヌ
グロヌバルaria-* 属性

When an input element's type attribute is in the Time state, the rules in this section apply.

input芁玠は、特定の時刻を衚す、芁玠の倀を蚭定する文字列に察するコントロヌルを衚す。

If the element is mutable, the user agent should allow the user to change the time represented by its value, as obtained by parsing a time from it. User agents must not allow the user to set the value to a non-empty string that is not a valid time string. If the user agent provides a user interface for selecting a time, then the value must be set to a valid time string representing the user's selection. User agents should allow the user to set the value to the empty string.

Constraint validation: While the user interface describes input that the user agent cannot convert to a valid time string, the control is suffering from bad input.

See the introduction section for a discussion of the difference between the input format and submission format for date, time, and number form controls, and the implementation notes regarding localization of form controls.

指定されおか぀空でない堎合、value属性は、劥圓な時刻文字列である倀を持たなければならない。

The value sanitization algorithm is as follows: If the value of the element is not a valid time string, then set it to the empty string instead.

The form control has a periodic domain.

min属性が指定された堎合、劥圓な時刻文字列ずなる倀を持たなければならない。max属性が指定された堎合、劥圓な時刻文字列ずなる倀を持たなければならない。

step属性は秒単䜍で衚される。The step scale factor is 1000 (which converts the seconds to milliseconds, as used in the other algorithms). The default step is 60 seconds.

When the element is suffering from a step mismatch, the user agent may round the element's value to the nearest time for which the element would not suffer from a step mismatch.

The algorithm to convert a string to a number, given a string input, is as follows: If parsing a time from input results in an error, then return an error; otherwise, return the number of milliseconds elapsed from midnight to the parsed time on a day with no time changes.

The algorithm to convert a number to a string, given a number input, is as follows: Return a valid time string that represents the time that is input milliseconds after midnight on a day with no time changes.

The algorithm to convert a string to a Date object, given a string input, is as follows: If parsing a time from input results in an error, then return an error; otherwise, return a new Date object representing the parsed time in UTC on 1970-01-01.

The algorithm to convert a Date object to a string, given a Date object input, is as follows: Return a valid time string that represents the UTC time component that is represented by input.

以䞋の共通input芁玠コンテンツ属性、IDL属性、およびメ゜ッドは芁玠に適甚するautocomplete、list、max、min、readonly、required、およびstepコンテンツ属性、list、value、valueAsDate、およびvalueAsNumberIDL属性、stepDown()およびstepUp()メ゜ッド。

valueIDL属性は、モヌドの倀ずなる。

inputおよびchangeむベントは適甚する。

以䞋のコンテンツ属性を指定しおはならず、芁玠に適甚しないaccept、alt、checked、dirname、formaction、formenctype、formmethod、formnovalidate、formtarget、height、maxlength、minlength、multiple、pattern、placeholder、size、src、width。

以䞋のIDL属性ずメ゜ッドは、芁玠に適甚しないchecked、files、selectionStart、selectionEnd、selectionDirectionIDL属性、select()、setRangeText()、setSelectionRange()メ゜ッド。

4.10.5.1.9 Number状態type=number
蚱可されるARIAロヌル属性倀
spinbutton デフォルト - 蚭定しない。
蚱可されるARIAステヌトおよびプロパティヌ
グロヌバルaria-* 属性
蚱可されるロヌルで受け入れ可胜な任意のaria-*属性。

When an input element's type attribute is in the Number state, the rules in this section apply.

input芁玠は、数倀を衚す文字列に芁玠の倀を蚭定する文字列に察するコントロヌルを衚す。

If the element is mutable, the user agent should allow the user to change the number represented by its value, as obtained from applying the rules for parsing floating-point number values to it. User agents must not allow the user to set the value to a non-empty string that is not a valid floating-point number. If the user agent provides a user interface for selecting a number, then the value must be set to the best representation of the number representing the user's selection as a floating-point number. User agents should allow the user to set the value to the empty string.

Constraint validation: While the user interface describes input that the user agent cannot convert to a valid floating-point number, the control is suffering from bad input.

この仕様は、ナヌザヌ゚ヌゞェントがどのようなナヌザヌむンタヌフェヌスを䜿甚するかを定矩しない。ナヌザヌ゚ヌゞェントのベンダヌは、最良のものをナヌザヌのニヌズに提䟛するよう考慮するこずが掚奚される。たずえば、ペルシャ語やアラビア語商圏においおナヌザヌ゚ヌゞェントは、ペルシャ語ずアラビア語の数字入力䞊蚘のように送信するために必芁な圢匏に倉換をサポヌトするだろう。同様に、ロヌマ人に蚭蚈されたナヌザヌ゚ヌゞェントは、小数よりもむしろロヌマ数字の倀を衚瀺するこずがある。たたはより珟実的にフランス垂堎向けに蚭蚈されたナヌザヌ゚ヌゞェントは1000ず小数の前のコンマずの間にアポストロフィで倀を衚瀺するこずがあり、内郚的に䞊蚘の送信圢匏に倉換しお、その方法で倀を入力できる。

指定されおか぀空でない堎合、value属性は、劥圓な浮動小数点数である倀を持たなければならない。

The value sanitization algorithm is as follows: If the value of the element is not a valid floating-point number, then set it to the empty string instead.

min属性が指定された堎合、劥圓な浮動小数点数ずなる倀を持たなければならない。max属性が指定された堎合、劥圓な浮動小数点数ずなる倀を持たなければならない。

The step scale factor is 1. The default step is 1 (allowing only integers to be selected by the user, unless the step base has a non-integer value).

When the element is suffering from a step mismatch, the user agent may round the element's value to the nearest number for which the element would not suffer from a step mismatch. If there are two such numbers, user agents are encouraged to pick the one nearest positive infinity.

The algorithm to convert a string to a number, given a string input, is as follows: If applying the rules for parsing floating-point number values to input results in an error, then return an error; otherwise, return the resulting number.

The algorithm to convert a number to a string, given a number input, is as follows: Return a valid floating-point number that represents input.

以䞋の共通input芁玠コンテンツ属性、IDL属性、およびメ゜ッドは芁玠に適甚するautocomplete、list、max、min、placeholder、readonly、requiredおよびstepコンテンツ属性、list、valueおよびvalueAsNumberIDL属性、stepDown()およびstepUp()メ゜ッド。

valueIDL属性は、モヌドの倀ずなる。

inputおよびchangeむベントは適甚する。

以䞋のコンテンツ属性を指定しおはならず、芁玠に適甚しないaccept、alt、checked、dirname、formaction、formenctype、formmethod、formnovalidate、formtarget、height、maxlength、minlength、multiple、pattern、size、src、width。

以䞋のIDL属性ずメ゜ッドは、芁玠に適甚しないchecked、files、selectionStart、selectionEnd、selectionDirection、valueAsDateIDL属性、select()、setRangeText()、setSelectionRange()メ゜ッド。

これは数倀入力制埡を䜿甚する䟋である

<label>How much do you want to charge? $<input type=number min=0 step=0.01 name=price></label>

䞊述したように、ナヌザヌ゚ヌゞェントは、送信するために必芁なフォヌマットに倉換し、ナヌザヌのロヌカルフォヌマットの数倀入力をサポヌトするかもしれない。これは、グルヌプ化区切り文字"872,000,000,000"のようにの凊理ず、様々な桁区切り蚘号たずえば"3,99"ず"3.99"たたはその土地の数字たずえばアラビア語、ヒンディヌ語、ペルシャ語、タむ語のものなどの䜿甚を含むかもしれない。

type=number状態は、数字のみで構成されるように出珟するが、厳密に番号を䌝えない入力に適さない。たずえば、クレゞットカヌド番号や米囜の郵䟿番号には䞍適切だろう。type=number決定する簡単な方法は、たずえば"up"ず"down"の矢印をも぀スピンボックスむンタヌフェヌスを持぀入力制埡が筋が通るかどうかを怜蚎するこずである。最埌の桁で1぀間違ったクレゞットカヌド番号の取埗は小さなミスではなく、すべおの桁を間違っお取埗するこずず同じである。よっお、ナヌザヌが"up"ず"down"ボタンを䜿甚しおクレゞットカヌド番号を遞択するこずは筋が通らないだろう。スピンボックスむンタヌフェヌスが適切でない堎合、type=textはおそらく正しい遞択であるおそらくpattern属性を持぀。

4.10.5.1.10 Range状態type=range
蚱可されるARIAロヌル属性倀
slider デフォルト - 蚭定しない。
蚱可されるARIAステヌトおよびプロパティヌ
グロヌバルaria-* 属性
蚱可されるロヌルで受け入れ可胜な任意のaria-*属性。

When an input element's type attribute is in the Range state, the rules in this section apply.

input芁玠は、数倀を衚す文字列に芁玠の倀を蚭定するためのコントロヌルを衚すが、正確な倀が重芁ではないずいう通知ずずもに、Number状態を提䟛するよりも単玔なむンタヌフェヌスをナヌザヌ゚ヌゞェントに提䟛させる。

この状態においお、範囲およびステップ制玄は、ナヌザヌ入力の間でさえも匷制され、そしお倀を空文字列に蚭定する方法は存圚しない。

If the element is mutable, the user agent should allow the user to change the number represented by its value, as obtained from applying the rules for parsing floating-point number values to it. User agents must not allow the user to set the value to a string that is not a valid floating-point number. If the user agent provides a user interface for selecting a number, then the value must be set to a best representation of the number representing the user's selection as a floating-point number. User agents must not allow the user to set the value to the empty string.

Constraint validation: While the user interface describes input that the user agent cannot convert to a valid floating-point number, the control is suffering from bad input.

value属性が指定された堎合、劥圓な浮動小数点数ずなる倀を持たなければならない。

The value sanitization algorithm is as follows: If the value of the element is not a valid floating-point number, then set it to a valid floating-point number that represents the default value.

min属性が指定された堎合、劥圓な浮動小数点数ずなる倀を持たなければならない。デフォルトの最小は0である。max属性が指定された堎合、劥圓な浮動小数点数ずなる倀を持たなければならない。デフォルトの最倧は100である。

デフォルト倀は、最小倀に最小倀ず最倧倀の差の半分を加えたものである。ただし、最倧倀が最小倀よりも小さい堎合を陀き、この堎合デフォルト倀が最小倀ずなる。

When the element is suffering from an underflow, the user agent must set the element's value to a valid floating-point number that represents the minimum.

When the element is suffering from an overflow, if the maximum is not less than the minimum, the user agent must set the element's value to a valid floating-point number that represents the maximum.

The step scale factor is 1. The default step is 1 (allowing only integers, unless the min attribute has a non-integer value).

When the element is suffering from a step mismatch, the user agent must round the element's value to the nearest number for which the element would not suffer from a step mismatch, and which is greater than or equal to the minimum, and, if the maximum is not less than the minimum, which is less than or equal to the maximum, if there is a number that matches these constraints. If two numbers match these constraints, then user agents must use the one nearest to positive infinity.

For example, the markup <input type="range" min=0 max=100 step=20 value=50> results in a range control whose initial value is 60.

The algorithm to convert a string to a number, given a string input, is as follows: If applying the rules for parsing floating-point number values to input results in an error, then return an error; otherwise, return the resulting number.

The algorithm to convert a number to a string, given a number input, is as follows: Return a valid floating-point number that represents input.

以䞋の共通input芁玠コンテンツ属性、IDL属性、およびメ゜ッドは芁玠に適甚するautocomplete、list、max、minおよびstepコンテンツ属性、list、valueおよびvalueAsNumberIDL属性、stepDown()およびstepUp()メ゜ッド。

valueIDL属性は、モヌドの倀ずなる。

inputおよびchangeむベントは適甚する。

以䞋のコンテンツ属性を指定しおはならず、芁玠に適甚しないaccept、alt、checked、dirname、formaction、formenctype、formmethod、formnovalidate、formtarget、height、maxlength、minlength、multiple、pattern、placeholder、readonly、required、size、src、width。

以䞋のIDL属性ずメ゜ッドは、芁玠に適甚しないchecked、files、selectionStart、selectionEnd、selectionDirection、valueAsDateIDL属性、select()、setRangeText()、setSelectionRange()メ゜ッド。

ここでlist属性をも぀オヌトコンプリヌトリストを䜿甚する範囲コントロヌルの䟋を瀺す。たずえば事前蚭定された光量、たたは速床コントロヌルずしお䜿甚される範囲コントロヌルで兞型的な速床制限など、特に重芁であるコントロヌルの完党な範囲に沿った倀が存圚する堎合、これは圹に立぀かもしれない。次のマヌクアップ断片で

<input type="range" min="-100" max="100" value="0" step="10" name="power" list="powers">
<datalist id="powers">
 <option value="0">
 <option value="-30">
 <option value="30">
 <option value="++50">
</datalist>

以䞋のスタむルシヌトが適甚されるずしお

input { height: 75px; width: 49px; background: #D5CCBB; color: black; }

このようにレンダリングされるかもしれない

A vertical slider control whose primary color is black and whose background color is beige, with the slider having five tick marks, one long one at each extremity, and three short ones clustered around the midpoint.

ナヌザヌ゚ヌゞェントがスタむルシヌトが指定した高さず幅のプロパティヌの比からコントロヌルの向きを決定する様子に泚意する。同様に色はスタむルシヌトから掟生したものである。しかし、目盛りはマヌクアップに由来である。具䜓的には、step属性は目盛りの配眮に圱響を䞎えず、ナヌザヌ゚ヌゞェントは著者が指定した終了倀を䜿甚するかを決定しおから、極端に長い目盛りを远加する。

無効な倀+50は、完党に無芖される様子にも泚意する。

ほかにも、以䞋のマヌクアップ断片を考えおみる

<input name=x type=range min=100 max=700 step=9.09090909 value=509.090909>

ナヌザヌ゚ヌゞェントは、様々な方法で衚瀺できる。たずえば

As a dial.

あるいは

As a long horizontal slider with tick marks.

ナヌザヌ゚ヌゞェントは、スタむルシヌトで指定された寞法に基づいお衚瀺するかを遞ぶこずができる。これは、幅の違いにもかかわらず、目盛りのために同じ解像床を維持するこずができるだろう。

最埌に、2぀のラベルの倀を持぀範囲コントロヌルの䟋を次に瀺す

<input type="range" name="a" list="a-values">
<datalist id="a-values">
 <option value="10" label="Low">
 <option value="90" label="High">
</datalist>

コントロヌルが垂盎に描画するスタむルずずもに、次のようになる

A vertical slider control with two tick marks, one near the top labeled 'High', and one near the bottom labeled 'Low'.

4.10.5.1.11 Color状態type=color
蚱可されるARIAロヌル属性倀
なし
蚱可されるARIAステヌトおよびプロパティヌ
グロヌバルaria-* 属性

When an input element's type attribute is in the Color state, the rules in this section apply.

input芁玠は、単玔色を衚す文字列に芁玠の倀を蚭定するための、色のコントロヌルを衚す。

In this state, there is always a color picked, and there is no way to set the value to the empty string.

If the element is mutable, the user agent should allow the user to change the color represented by its value, as obtained from applying the rules for parsing simple color values to it. User agents must not allow the user to set the value to a string that is not a valid lowercase simple color. If the user agent provides a user interface for selecting a color, then the value must be set to the result of using the rules for serializing simple color values to the user's selection. User agents must not allow the user to set the value to the empty string.

Constraint validation: While the user interface describes input that the user agent cannot convert to a valid lowercase simple color, the control is suffering from bad input.

指定されおか぀空でない堎合、value属性は、劥圓な単玔色である倀を持たなければならない。

The value sanitization algorithm is as follows: If the value of the element is a valid simple color, then set it to the value of the element converted to ASCII lowercase; otherwise, set it to the string "#000000".

以䞋の共通input芁玠のコンテンツ属性およびIDL属性は芁玠に適甚するautocompleteおよびlistコンテンツ属性、listおよびvalueIDL属性。

valueIDL属性は、モヌドの倀ずなる。

inputおよびchangeむベントは適甚する。

以䞋のコンテンツ属性を指定しおはならず、芁玠に適甚しないaccept、alt、checked、dirname、formaction、formenctype、formmethod、formnovalidate、formtarget、height、max、maxlength、min、minlength、multiple、pattern、placeholder、readonly、required、size、src、step、width。

以䞋のIDL属性ずメ゜ッドは、芁玠に適甚しないchecked、files、selectionStart、selectionEnd、selectionDirection、valueAsDate、valueAsNumberIDL属性、select()、setRangeText()、setSelectionRange()、stepDown()、stepUp()メ゜ッド。

4.10.5.1.12 Checkbox状態type=checkbox
蚱可されるARIAロヌル属性倀
checkboxデフォルト - 蚭定しないたたはmenuitemcheckbox。
蚱可されるARIAステヌトおよびプロパティヌ
グロヌバルaria-* 属性
蚱可されるロヌルで受け入れ可胜な任意のaria-*属性。

When an input element's type attribute is in the Checkbox state, the rules in this section apply.

input芁玠は、その芁玠のcheckedness状態を衚す2状態コントロヌルを衚す。芁玠のcheckedness状態がtrueの堎合、コントロヌルは正の遞択を衚し、falseの堎合、負の遞択を衚す。芁玠のindeterminate DOM属性がtrueに蚭定される堎合、あたかもコントロヌルが第3の状態である、䞍確定であったかのように、コントロヌルの遞択を隠すべきである。

たずえ芁玠のindeterminateIDL属性がtrueに蚭定されおも、コントロヌルはtrueの3状態ではない。indeterminateIDL属性は、第3の状態の倖芳を䞎える。

If the element is mutable, then: The pre-click activation steps consist of setting the element's checkedness to its opposite value (i.e. true if it is false, false if it is true), and of setting the element's indeterminate IDL attribute to false. The canceled activation steps consist of setting the checkedness and the element's indeterminate IDL attribute back to the values they had before the pre-click activation steps were run. The activation behavior is to fire a simple event that bubbles named input at the element and then fire a simple event that bubbles named change at the element.

If the element is not mutable, it has no activation behavior.

Constraint validation: If the element is required and its checkedness is false, then the element is suffering from being missing.

input . indeterminate [ = value ]

蚭定する堎合、checkboxコントロヌルの衚瀺は、珟圚の倀が衚瀺されないように䞊曞きする。

以䞋の共通input芁玠コンテンツ属性、IDL属性、およびメ゜ッドは芁玠に適甚するcheckedおよびrequiredコンテンツ属性、checkedおよびvalueIDL属性。

valueIDL属性はモヌドdefault/onずなる。

inputおよびchangeむベントは適甚する。

以䞋のコンテンツ属性を指定しおはならず、芁玠に適甚しないaccept、alt、autocomplete、dirname、formaction、formenctype、formmethod、formnovalidate、formtarget、height、list、max、maxlength、min、minlength、multiple、pattern、placeholder、readonly、size、src、step、width。

以䞋のIDL属性ずメ゜ッドは、芁玠に適甚しないfiles、list、selectionStart、selectionEnd、selectionDirection、valueAsDate、valueAsNumberIDL属性、select()、setRangeText()、setSelectionRange()、stepDown()、stepUp()メ゜ッド。

4.10.5.1.13 Radio Button状態type=radio
蚱可されるARIAロヌル属性倀
radioデフォルト - 蚭定しないたたはmenuitemradio。
蚱可されるARIAステヌトおよびプロパティヌ
グロヌバルaria-* 属性
蚱可されるロヌルで受け入れ可胜な任意のaria-*属性。

When an input element's type attribute is in the Radio Button state, the rules in this section apply.

input芁玠は、他のinput芁玠ず組み合わせお䜿甚した堎合、1぀のみのコントロヌルがそのcheckedness状態をtrueに蚭定させるこずができるラゞオボタングルヌプを圢成するコントロヌルを衚す。芁玠のcheckedness状態がtrueである堎合、コントロヌルは、グルヌプ内の遞択されたコントロヌルを衚し、falseである堎合、遞択されおないグルヌプ内のコントロヌルを瀺す。

input芁玠aを含むラゞオボタングルヌプはたた、次のすべおの条件を満たす他のinput芁玠bを含む

文曞は、ラゞオボタングルヌプがその芁玠のみを含むinput芁玠を含めおはならない。

When any of the following phenomena occur, if the element's checkedness state is true after the occurrence, the checkedness state of all the other elements in the same radio button group must be set to false:

If the element is mutable, then: The pre-click activation steps consist of setting the element's checkedness to true. The canceled activation steps consist of setting the element's checkedness to false. The activation behavior is to fire a simple event that bubbles named input at the element and then fire a simple event that bubbles named change at the element.

If the element is not mutable, it has no activation behavior.

Constraint validation: If an element in the radio button group is required, and all of the input elements in the radio button group have a checkedness that is false, then the element is suffering from being missing.

ボタンが文曞に挿入された際に、ラゞオボタングルヌプ内のラゞオボタンがいずれもチェックされない堎合、ナヌザヌたたはスクリプトのいずれかによっおボタンの1぀がチェックされるようになるたで、むンタヌフェヌスで初期にチェックされないだろう。

以䞋の共通input芁玠コンテンツ属性、IDL属性、およびメ゜ッドは芁玠に適甚するcheckedおよびrequiredコンテンツ属性、checkedおよびvalueIDL属性。

valueIDL属性はモヌドdefault/onずなる。

inputおよびchangeむベントは適甚する。

以䞋のコンテンツ属性を指定しおはならず、芁玠に適甚しないaccept、alt、autocomplete、dirname、formaction、formenctype、formmethod、formnovalidate、formtarget、height、list、max、maxlength、min、minlength、multiple、pattern、placeholder、readonly、size、src、step、width。

以䞋のIDL属性ずメ゜ッドは、芁玠に適甚しないfiles、list、selectionStart、selectionEnd、selectionDirection、valueAsDate、valueAsNumberIDL属性、select()、setRangeText()、setSelectionRange()、stepDown()、stepUp()メ゜ッド。

4.10.5.1.14 File Upload状態type=file
蚱可されるARIAロヌル属性倀
なし
蚱可されるARIAステヌトおよびプロパティヌ
グロヌバルaria-* 属性

When an input element's type attribute is in the File Upload state, the rules in this section apply.

input芁玠は、各ファむルがファむル名、ファむルタむプ、ファむル本䜓ファむルの内容で構成される、遞択されたファむルのリストを衚す。

File names must not contain path components, even in the case that a user has selected an entire directory hierarchy or multiple files with the same name from different directories.

Unless the multiple attribute is set, there must be no more than one file in the list of selected files.

If the element is mutable, then the element's activation behavior is to run the following steps:

  1. If the algorithm is not allowed to show a popup, then abort these steps without doing anything else.

  2. Return, but continue running these steps asynchronously.

  3. Optionally, wait until any prior execution of this algorithm has terminated.

  4. Display a prompt to the user requesting that the user specify some files. If the multiple attribute is not set, there must be no more than one file selected; otherwise, any number may be selected. Files can be from the filesystem or created on the fly, e.g. a picture taken from a camera connected to the user's device.

  5. Wait for the user to have made their selection.

  6. Queue a task to first update the element's selected files so that it represents the user's selection, then fire a simple event that bubbles named input at the input element, and finally fire a simple event that bubbles named change at the input element.

If the element is mutable, the user agent should allow the user to change the files on the list in other ways also, e.g. adding or removing files by drag-and-drop. When the user does so, the user agent must queue a task to first update the element's selected files so that it represents the user's new selection, then fire a simple event that bubbles named input at the input element, and finally fire a simple event that bubbles named change at the input element.

If the element is not mutable, it has no activation behavior and the user agent must not allow the user to change the element's selection.

Constraint validation: If the element is required and the list of selected files is empty, then the element is suffering from being missing.


accept属性は、どのファむルタむプが受け入れられるかのヒントずずもにナヌザヌ゚ヌゞェントを提䟛するために指定されおもよい。

指定された堎合、この属性は、次のいずれかずASCII倧文字・小文字䞍区別で䞀臎しなければならない、それぞれがカンマ区切りのトヌクンのセットで構成しなければならない。

文字列audio/*
音声ファむルが受け入れられるこずを瀺す。
文字列video/*
動画ファむルが受け入れられるこずを瀺す。
文字列image/*
画像ファむルが受け入れられるこずを瀺す。
パラメヌタのない劥圓なMIMEタむプ
指定された型のファむルが受け入れられるこずを瀺す。
最初の文字が"."U+002E文字である文字列
指定されたファむル拡匵をも぀ファむルが受け入れられるこずを瀺す。

トヌクンは、他のトヌクンのいずれかずASCII倧文字・小文字䞍区別で䞀臎しおはならない぀たり重耇は蚱可されない。To obtain the list of tokens from the attribute, the user agent must split the attribute value on commas.

ナヌザヌ゚ヌゞェントは、䞀般的なファむルピッカヌよりも適切なナヌザヌむンタヌフェヌスを衚瀺するためにこの属性の倀を䜿甚しおもよい。たずえば、倀image/*を䞎えられるず、ナヌザヌ゚ヌゞェントはナヌザヌにロヌカルカメラのオプションや、写真コレクションから写真の遞択を提䟛できる。倀audio/*を䞎えられるず、ナヌザヌ゚ヌゞェントは、ナヌザヌにヘッドセットのマむクを䜿甚しおクリップを蚘録するオプションを提䟛できる。

User agents should prevent the user from selecting files that are not accepted by one (or more) of these tokens.

著者は、特定の圢匏でデヌタを怜玢する際、任意のMIMEタむプず察応する拡匵子の䞡方を指定するこずが掚奚される。

たずえば、Microsoft Word文曞をOpen Document圢匏のファむルに倉換するアプリケヌションを考えおみる。Microsoft Word文曞は倚皮倚様なMIMEタむプず拡匵子で蚘茉されるので、次のように、サむトは耇数列挙できる

<input type="file" accept=".doc,.docx,.xml,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document">

ファむルの皮類を蚘述するためにファむル拡匵子のみを䜿甚するプラットフォヌム䞊で、もしあれば、他の拡匵子を刀別するために、MIMEタむプがシステムの型登録テヌブルシステムで䜿甚される拡匵子にMIMEタむプを察応付けるずずもに䜿甚できるず同時に、ここに蚘茉される拡匵子は、蚱可された文曞をフィルタするために䜿甚できる。同様に、システムがファむル名たたは拡匵子を持たないが、内郚的にMIMEタむプをも぀文曞を識別するシステムで、システムで䜿甚されるMIMEタむプに既知の拡匵子を察応づける拡匵子登録テヌブルをシステムが持぀堎合、拡匵子を䜿甚できるず同時に、MIMEタむプは蚱可されたファむルを遞択するために䜿甚できる。

拡匵子は曖昧になる傟向がありたずえば、".dat"拡匵子を䜿甚する莫倧な数のフォヌマットが存圚しおおり、Microsoft Wordの文曞でない堎合でも、ナヌザヌは通垞、非垞に簡単に".doc"ずいう拡匵子を持぀ファむル名に倉曎できる、そしおMIMEタむプは信頌性が䜎くなる傟向があるたずえば、倚くのフォヌマットは正匏に登録された型を持たず、実際に倚くのフォヌマットが倚数の異なるMIMEタむプを甚いお識別される。ナヌザヌが敵察的でなく、ナヌザヌ゚ヌゞェントが完党にaccept属性の芁件に埓った堎合であっおも、それが期埅されるフォヌマットでないかもしれないので、著者は通垞、クラむアントから受信したデヌタが慎重に扱われるべきであるこずに泚意する。

歎史的な理由により、value IDL属性は、ファむル名に文字列"C:\fakepath\"を接頭蟞ずしお付ける。䞀郚のレガシヌナヌザヌ゚ヌゞェントは、実際にセキュリティヌ䞊の脆匱性があった完党なパスを含む。この結果ずしお、埌方互換性のある方法でvalue IDL属性からファむル名を取埗するこずは自明ではない。次の関数は適切に互換性のある方法でファむル名を抜出する

function extractFilename(path) {
  if (path.substr(0, 12) == "C:\\fakepath\\")
    return path.substr(12); // modern browser
  var x;
  x = path.lastIndexOf('/');
  if (x >= 0) // Unix-based path
    return path.substr(x+1);
  x = path.lastIndexOf('\\');
  if (x >= 0) // Windows-based path
    return path.substr(x+1);
  return path; // just the file name
}

これは次のように䜿甚できる

<p><input type=file name=image onchange="updateFilename(this.value)"></p>
<p>The name of the file you picked is: <span id="filename">(none)</span></p>
<script>
 function updateFilename(path) {
   var name = extractFilename(path);
   document.getElementById('filename').textContent = name;
 }
</script>

以䞋の共通input芁玠コンテンツ属性、IDL属性、およびメ゜ッドは芁玠に適甚するaccept、multiple、requiredコンテンツ属性、files、valueIDL属性。

value IDL属性は、モヌドのファむル名ずなる。

inputおよびchangeむベントは適甚する。

以䞋のコンテンツ属性を指定しおはならず、芁玠に適甚しないaccept、alt、autocomplete、dirname、formaction、formenctype、formmethod、formnovalidate、formtarget、height、list、max、maxlength、min、minlength、pattern、placeholder、readonly、size、src、step、width。

芁玠のvalue属性は省略しなければならない。

以䞋のIDL属性ずメ゜ッドは、芁玠に適甚しないchecked、list、selectionStart、selectionEnd、selectionDirection、valueAsDate、valueAsNumberIDL属性、select()、setRangeText()、setSelectionRange()、stepDown()、stepUp()メ゜ッド。

4.10.5.1.15 Submit Button状態type=submit
蚱可されるARIAロヌル属性倀
button デフォルト - 蚭定しない。
蚱可されるARIAステヌトおよびプロパティヌ
グロヌバルaria-* 属性
蚱可されるロヌルで受け入れ可胜な任意のaria-*属性。

When an input element's type attribute is in the Submit Button state, the rules in this section apply.

input芁玠は、アクティブになった際、フォヌムを送信するボタンを衚す。If the element has a value attribute, the button's label must be the value of that attribute; otherwise, it must be an implementation-defined string that means "Submit" or some such. The element is a button, specifically a submit button. (This is a fingerprinting vector.)

If the element is mutable, then the element's activation behavior is as follows: if the element has a form owner, and the element's Document is fully active, submit the form owner from the input element; otherwise, do nothing.

If the element is not mutable, it has no activation behavior.

formaction、formenctype、formmethod、formnovalidate、formtarget属性は、フォヌム送信甚の属性である。

formnovalidate属性は、制玄怜蚌をトリガヌしない送信ボタンを䜜成するために䜿甚できる。

以䞋の共通input芁玠コンテンツ属性、IDL属性、およびメ゜ッドは芁玠に適甚するformaction、formenctype、formmethod、formnovalidate、およびformtargetコンテンツ属性、value IDL属性。

value IDL属性はモヌドdefaultずなる。

以䞋のコンテンツ属性を指定しおはならず、芁玠に適甚しないaccept、alt、autocomplete、checked、dirname、height、list、max、maxlength、min、minlength、multiple、pattern、placeholder、readonly、required、size、src、step、width。

以䞋のIDL属性ずメ゜ッドは、芁玠に適甚しないchecked、files、list、selectionStart、selectionEnd、selectionDirection、valueAsDate、valueAsNumber IDL属性、select()、setRangeText()、setSelectionRange()、stepDown()、stepUp()メ゜ッド。

inputおよびchangeむベントは適甚しない。

4.10.5.1.16 Image Button状態type=image
蚱可されるARIAロヌル属性倀
button デフォルト - 蚭定しない、link、menuitem、menuitemcheckbox、menuitemradioたたはradio。
蚱可されるARIAステヌトおよびプロパティヌ
グロヌバルaria-* 属性
蚱可されるロヌルで受け入れ可胜な任意のaria-*属性。

When an input element's type attribute is in the Image Button state, the rules in this section apply.

input芁玠は、ナヌザヌが座暙を遞択しおフォヌムを送信する画像、たたは代わりに、ナヌザヌがフォヌムを送信できるボタンを衚す。芁玠は、具䜓的に送信ボタンずなるボタンである。

座暙に察する2぀の゚ントリヌを送信するこずによっおフォヌムの送信時にサヌバヌに送信され、制埡の名前から埗られるが、".x"ず".y"はそれぞれの座暙のxずy成分をも぀名前に付加される。


画像はsrc属性によっお指定される。src属性は存圚しなければならず、画像リ゜ヌスは朜圚的にペヌゞ化もスクリプト化もされおいない、任意でアニメヌションである、非察話型を参照する朜圚的にスペヌスで囲たれた劥圓な空でないURLを含めなければならない。

When any of the following events occur, unless the user agent cannot support images, or its support for images has been disabled, or the user agent only fetches elements on demand, or the src attribute's value is the empty string, the user agent must resolve the value of the src attribute, relative to the element, and if that is successful, must fetch the resulting absolute URL:

Fetching the image must delay the load event of the element's document until the task that is queued by the networking task source once the resource has been fetched (defined below) has been run.

If the image was successfully obtained, with no network errors, and the image's type is a supported image type, and the image is a valid image of that type, then the image is said to be available. If this is true before the image is completely downloaded, each task that is queued by the networking task source while the image is being fetched must update the presentation of the image appropriately.

The user agent should apply the image sniffing rules to determine the type of the image, with the image's associated Content-Type headers giving the official type. If these rules are not applied, then the type of the image must be the type given by the image's associated Content-Type headers.

User agents must not support non-image resources with the input element. User agents must not run executable code embedded in the image resource. User agents must only display the first page of a multipage resource. User agents must not allow the resource to act in an interactive fashion, but should honor any animation in the resource.

The task that is queued by the networking task source once the resource has been fetched, must, if the download was successful and the image is available, queue a task to fire a simple event named load at the input element; and otherwise, if the fetching process fails without a response from the remote server, or completes but the image is not a valid or supported image, queue a task to fire a simple event named error on the input element.


alt属性は、画像を䜿甚できないナヌザヌおよびナヌザヌ゚ヌゞェントのためにボタンのテキストラベルを提䟛する。alt属性は存圚しなければならず、画像が利甚できなかった堎合に等䟡なボタンに察しお適切だろうラベルを䞎える空でない文字列を含たなければならない。

input芁玠は、寞法属性をサポヌトする。


If the src attribute is set, and the image is available and the user agent is configured to display that image, then: The element represents a control for selecting a coordinate from the image specified by the src attribute; if the element is mutable, the user agent should allow the user to select this coordinate, and the element's activation behavior is as follows: if the element has a form owner, and the element's Document is fully active, take the user's selected coordinate, and submit the input element's form owner from the input element. If the user activates the control without explicitly selecting a coordinate, then the coordinate (0,0) must be assumed.

Otherwise, the element represents a submit button whose label is given by the value of the alt attribute; if the element is mutable, then the element's activation behavior is as follows: if the element has a form owner, and the element's Document is fully active, set the selected coordinate to (0,0), and submit the input element's form owner from the input element.

In either case, if the element is mutable but has no form owner or the element's Document is not fully active, then its activation behavior must be to do nothing. If the element is not mutable, it has no activation behavior.

The selected coordinate must consist of an x-component and a y-component. The coordinates represent the position relative to the edge of the image, with the coordinate space having the positive x direction to the right, and the positive y direction downwards.

The x-component must be a valid integer representing a number x in the range −(borderleft+paddingleft) ≀ x ≀ width+borderright+paddingright, where width is the rendered width of the image, borderleft is the width of the border on the left of the image, paddingleft is the width of the padding on the left of the image, borderright is the width of the border on the right of the image, and paddingright is the width of the padding on the right of the image, with all dimensions given in CSS pixels.

The y-component must be a valid integer representing a number y in the range −(bordertop+paddingtop) ≀ y ≀ height+borderbottom+paddingbottom, where height is the rendered height of the image, bordertop is the width of the border above the image, paddingtop is the width of the padding above the image, borderbottom is the width of the border below the image, and paddingbottom is the width of the padding below the image, with all dimensions given in CSS pixels.

Where a border or padding is missing, its width is zero CSS pixels.


formaction、formenctype、formmethod、formnovalidate、formtarget属性は、フォヌム送信甚の属性である。

image . width [ = value ]
image . height [ = value ]

これらの属性は、実際のレンダリングされた画像の倧きさ、たたは寞法が未知である堎合に0を返す。

察応するコンテンツ属性を倉曎するために、蚭定が可胜である。

以䞋の共通input芁玠コンテンツ属性、IDL属性、およびメ゜ッドは芁玠に適甚するalt、formaction、formenctype、formmethod、formnovalidate、formtarget、height、srcおよびwidthコンテンツ属性、value IDL属性。

value IDL属性はモヌドdefaultずなる。

以䞋のコンテンツ属性を指定しおはならず、芁玠に適甚しないaccept、autocomplete、checked、dirname、list、max、maxlength、min、minlength、multiple、pattern、placeholder、readonly、required、size、step。

芁玠のvalue属性は省略しなければならない。

以䞋のIDL属性ずメ゜ッドは、芁玠に適甚しないchecked、files、list、selectionStart、selectionEnd、selectionDirection、valueAsDate、valueAsNumber IDL属性、select()、setRangeText()、setSelectionRange()、stepDown()、stepUp()メ゜ッド。

inputおよびchangeむベントは適甚しない。

この状態の挙動に関しお倚くの偎面は、img芁玠の挙動に䌌おいる。読者は、同じ芁件の倚くがより詳现に蚘茉される節を読むこずを掚奚する。

次のフォヌムを取るず

<form action="process.cgi">
 <input type=image src=map.png name=where alt="Show location list">
</form>

ナヌザヌが座暙127,40で画像をクリックした堎合、フォヌムを送信するために䜿甚されるURLは"process.cgi?where.x=127&where.y=40"ずなる。

この䟋においお、マップが衚瀺されないナヌザヌ、および"Show location list"ずいうラベルの付いたボタンが衚瀺されたナヌザヌを仮定し、ボタンをクリックするこずはマップの代わりから遞択する堎所のリストの衚瀺をサヌバヌにさせる。

4.10.5.1.17 Reset Button状態type=reset
蚱可されるARIAロヌル属性倀
button デフォルト - 蚭定しない。
蚱可されるARIAステヌトおよびプロパティヌ
グロヌバルaria-* 属性
蚱可されるロヌルで受け入れ可胜な任意のaria-*属性。

When an input element's type attribute is in the Reset Button state, the rules in this section apply.

アクティブの際、input芁玠は、フォヌムをリセットするボタンを衚す。If the element has a value attribute, the button's label must be the value of that attribute; otherwise, it must be an implementation-defined string that means "Reset" or some such. The element is a button. (This is a fingerprinting vector.)

If the element is mutable, then the element's activation behavior, if the element has a form owner and the element's Document is fully active, is to reset the form owner; otherwise, it is to do nothing.

If the element is not mutable, it has no activation behavior.

Constraint validation: The element is barred from constraint validation.

valueIDL属性は、この芁玠に適甚され、モヌドのデフォルトずなる。

以䞋のコンテンツ属性を指定しおはならず、芁玠に適甚しないaccept、alt、autocomplete、checked、dirname、formaction、formenctype、formmethod、formnovalidate、formtarget、height、list、max、maxlength、min、minlength、multiple、pattern、placeholder、readonly、required、size、src、step、width。

以䞋のIDL属性ずメ゜ッドは、芁玠に適甚しないchecked、files、list、selectionStart、selectionEnd、selectionDirection、valueAsDate、valueAsNumber IDL属性、select()、setRangeText()、setSelectionRange()、stepDown()、stepUp()メ゜ッド。

inputおよびchangeむベントは適甚しない。

4.10.5.1.18 Button状態type=button
蚱可されるARIAロヌル属性倀
button デフォルト - 蚭定しない、link、menuitem、menuitemcheckbox、menuitemradioたたはradio。
蚱可されるARIAステヌトおよびプロパティヌ
グロヌバルaria-* 属性
蚱可されるロヌルで受け入れ可胜な任意のaria-*属性。

When an input element's type attribute is in the Button state, the rules in this section apply.

input芁玠は、デフォルトの動䜜をもたないボタンを衚す。芁玠が空文字列であるかもしれないが、ボタンのラベルは、value属性で指定されなければならない。If the element has a value attribute, the button's label must be the value of that attribute; otherwise, it must be the empty string. The element is a button.

If the element is mutable, the element's activation behavior is to do nothing.

If the element is not mutable, it has no activation behavior.

Constraint validation: The element is barred from constraint validation.

valueIDL属性は、この芁玠に適甚され、モヌドのデフォルトずなる。

以䞋のコンテンツ属性を指定しおはならず、芁玠に適甚しないaccept、alt、autocomplete、checked、dirname、formaction、formenctype、formmethod、formnovalidate、formtarget、height、list、max、maxlength、min、minlength、multiple、pattern、placeholder、readonly、required、size、src、step、width。

以䞋のIDL属性ずメ゜ッドは、芁玠に適甚しないchecked、files、list、selectionStart、selectionEnd、selectionDirection、valueAsDate、valueAsNumber IDL属性、select()、setRangeText()、setSelectionRange()、stepDown()、stepUp()メ゜ッド。

inputおよびchangeむベントは適甚しない。

4.10.5.2 Implemention notes regarding localization of form controls

この節は非芏範的である。

The formats shown to the user in date, time, and number controls is independent of the format used for form submission.

Browsers are encouraged to use user interfaces that present dates, times, and numbers according to the conventions of either the locale implied by the input element's language or the user's preferred locale. Using the page's locale will ensure consistency with page-provided data.

For example, it would be confusing to users if an American English page claimed that a Cirque De Soleil show was going to be showing on 02/03, but their browser, configured to use the British English locale, only showed the date 03/02 in the ticket purchase date picker. Using the page's locale would at least ensure that the date was presented in the same format everywhere. (There's still a risk that the user would end up arriving a month late, of course, but there's only so much that can be done about such cultural differences...)

4.10.5.3 共通input芁玠属性

These attributes only apply to an input element if its type attribute is in a state whose definition declares that the attribute applies. When an attribute doesn't apply to an input element, user agents must ignore the attribute, regardless of the requirements and definitions below.

4.10.5.3.1 minおよびmax属性

The maxlength attribute, when it applies, is a form control maxlength attribute controlled by the input element's dirty value flag.

The minlength attribute, when it applies, is a form control minlength attribute controlled by the input element's dirty value flag.

input芁玠が最倧蚱容倀の長さを持぀堎合、その芁玠のvalue属性倀に属するコヌド単䜍長さは、芁玠の最倧蚱容倀の長さ以䞋でなければならない。

次の抜粋は、簡朔であるようなこの媒䜓を通した任意の䌚話を匷制しおむンテリゞェントな談話に反察するような、メッセヌゞングクラむアントのテキスト入力が任意に固定文字数に制限できる方法を瀺す。

<label>What are you doing? <input name=status maxlength=140></label>

ここでは、パスワヌドが最小の長さを䞎えられる

<p><label>Username: <input name=u required></label>
<p><label>Password: <input name=p required minlength=12></label>
4.10.5.3.2 size属性

芖芚的なレンダリングにおいお、size属性は、ナヌザヌ゚ヌゞェントが芁玠の倀を線集しおいる間にナヌザヌが参照できるようにする、文字数を䞎える。

size属性が指定される堎合、れロより倧きい劥圓な負でない敎数である倀を持たなければならない。

If the attribute is present, then its value must be parsed using the rules for parsing non-negative integers, and if the result is a number greater than zero, then the user agent should ensure that at least that many characters are visible.

The size IDL attribute is limited to only non-negative numbers greater than zero and has a default value of 20.

4.10.5.3.3 readonly属性

readonly属性は、ナヌザヌがフォヌムコントロヌルを線集できるかどうかを制埡する真停属性である。When specified, the element is not mutable.

Constraint validation: If the readonly attribute is specified on an input element, the element is barred from constraint validation.

disabledずreadonlyずの違いは、無効なコントロヌルに非察話型であるのに察し、読み取り専甚コントロヌルは、䟝然ずしおフォヌカス可胜であるので、ナヌザヌはただテキストを遞択し察話できる。このような理由から、テキストのみのコントロヌルは読み取り専甚にできる。たずえば、チェックボックスやボタンの意味をなさないだろう。

次の䟋においお、既存の補品識別子は倉曎できないが、識別子がただ入力されおいない堎所で新補品を衚す行ずの䞀貫性を保぀ために、それらは䟝然ずしおフォヌムの䞀郚ずしお衚瀺される。

<form action="products.cgi" method="post" enctype="multipart/form-data">
 <table>
  <tr> <th> Product ID <th> Product name <th> Price <th> Action
  <tr>
   <td> <input readonly="readonly" name="1.pid" value="H412">
   <td> <input required="required" name="1.pname" value="Floor lamp Ulke">
   <td> $<input required="required" type="number" min="0" step="0.01" name="1.pprice" value="49.99">
   <td> <button formnovalidate="formnovalidate" name="action" value="delete:1">Delete</button>
  <tr>
   <td> <input readonly="readonly" name="2.pid" value="FG28">
   <td> <input required="required" name="2.pname" value="Table lamp Ulke">
   <td> $<input required="required" type="number" min="0" step="0.01" name="2.pprice" value="24.99">
   <td> <button formnovalidate="formnovalidate" name="action" value="delete:2">Delete</button>
  <tr>
   <td> <input required="required" name="3.pid" value="" pattern="[A-Z0-9]+">
   <td> <input required="required" name="3.pname" value="">
   <td> $<input required="required" type="number" min="0" step="0.01" name="3.pprice" value="">
   <td> <button formnovalidate="formnovalidate" name="action" value="delete:3">Delete</button>
 </table>
 <p> <button formnovalidate="formnovalidate" name="action" value="add">Add</button> </p>
 <p> <button name="action" value="update">Save</button> </p>
</form>
4.10.5.3.4 required属性

required属性は真停属性である。指定される堎合、芁玠はrequiredずなる。

Constraint validation: If the element is required, and its value IDL attribute applies and is in the mode value, and the element is mutable, and the element's value is the empty string, then the element is suffering from being missing.

以䞋のフォヌムは、電子メヌルアドレスに察しおおよびパスワヌドに察しおの2぀の必須フィヌルドを持぀。フォヌムはたた、ナヌザヌがパスワヌドフィヌルドおよび3぀目のフィヌルドで同じパスワヌドを打ち蟌む堎合に、劥圓であるずみなされる3぀目のフィヌルドを持぀。

<h1>Create new account</h1>
<form action="/newaccount" method=post
      oninput="up2.setCustomValidity(up2.value != up.value ? 'Passwords do not match.' : '')">
 <p>
  <label for="username">E-mail address:</label>
  <input id="username" type=email required name=un>
 <p>
  <label for="password1">Password:</label>
  <input id="password1" type=password required name=up>
 <p>
  <label for="password2">Confirm password:</label>
  <input id="password2" type=password name=up2>
 <p>
  <input type=submit value="Create account">
</form>

ラゞオボタンに察しお、グルヌプ内のラゞオボタンのいずれかが遞択されおいる堎合、required属性は満たされる。したがっお次の䟋においお、必須ずしおマヌクされる1぀のみでなく、ラゞオボタンのいずれかがチェックされうる。

<fieldset>
 <legend>Did the movie pass the Bechdel test?</legend>
 <p><label><input type="radio" name="bechdel" value="no-characters"> No, there are not even two female characters in the movie. </label>
 <p><label><input type="radio" name="bechdel" value="no-names"> No, the female characters never talk to each other. </label>
 <p><label><input type="radio" name="bechdel" value="no-topic"> No, when female characters talk to each other it's always about a male character. </label>
 <p><label><input type="radio" name="bechdel" value="yes" required> Yes. </label>
 <p><label><input type="radio" name="bechdel" value="unknown"> I don't know. </label>
</fieldset>

ラゞオボタングルヌプが必須ずされるかどうかにかかわらず、混乱を避けるために、著者は、グルヌプ内のすべおのラゞオボタンで属性を指定するこずが掚奚される。実際䞀般に、これはナヌザヌが戻るこずができない状態であるため、著者は、最初の堎所で任意の最初にチェックするコントロヌルを持たないラゞオボタングルヌプを回避するこずが掚奚されおおり、したがっお䞀般に貧匱なナヌザヌむンタヌフェヌスず芋なされる。

4.10.5.3.5 multiple属性

multiple属性は、ナヌザヌに耇数の倀を指定するこずを蚱可するかどうかを瀺す真停属性である。

以䞋の抜粋は、電子メヌルクラむアントの"Cc"のフィヌルドが耇数の電子メヌルアドレスを受け入れるこずができる方法を瀺す。

<label>Cc: <input type=email multiple name=cc></label>

ナヌザヌの連絡先デヌタベヌスで倚くの友人の間で、ナヌザヌが、2人の友人"Arthur Dent"アドレス"art@example.net"ず"Adam Josh"アドレス"adamjosh@example.net"持っおいた堎合、ナヌザヌが"a"を入力した埌に、ナヌザヌ゚ヌゞェントは、ナヌザヌにこれら2぀の電子メヌルアドレスを掚奚するかもしれない。

Form control group containing 'Send', 
   'Save now' and 'Discard' buttons, a 'To:' combo box with an 'a' displayed in the text box and 2 list items below.

このペヌゞはたた、サむトからナヌザヌの連絡先デヌタベヌスにリンクできる

<label>Cc: <input type=email multiple name=cc list=contacts></label>
...
<datalist id="contacts">
 <option value="hedral@damowmow.com">
 <option value="pillar@example.com">
 <option value="astrophy@cute.example">
 <option value="astronomy@science.example.org">
</datalist>

ナヌザヌがこのテキストフィヌルドに"bob@example.net"を入力した埌、"a"で始たる2番目の電子メヌルアドレスを入力し始めおいたず仮定する。ナヌザヌ゚ヌゞェントは、前述した2人の友人だけでなく、datalist芁玠で指定された"astrophy"ず"astronomy"の倀の䞡方を衚瀺するかもしれない。

Form control group containing 'send', 
   'save now' and 'discard' buttons and a 'To:' combo box with 'bob@example.net,a' displayed in the text box and 4 list items below.

次の抜粋は、電子メヌルクラむアントの"Attachments"フィヌルドが、アップロヌド甚に耇数ファむルを受け入れるこずができる様子を瀺す。

<label>Attachments: <input type=file multiple name=att></label>
4.10.5.3.6 pattern属性

pattern属性は、コントロヌルの倀すなわち、multiple属性が適甚されお蚭定される堎合、コントロヌルの耇数の倀がチェックされる察象ずなる正芏衚珟を指定する。

指定された堎合、属性倀は、JavaScriptパタヌン生成芏則にマッチしなければならない。[ECMA262]

If an input element has a pattern attribute specified, and the attribute's value, when compiled as a JavaScript regular expression with the global, ignoreCase, and multiline flags disabled (see ECMA262 Edition 5, sections 15.10.7.2 through 15.10.7.4), compiles successfully, then the resulting regular expression is the element's compiled pattern regular expression. If the element has no such attribute, or if the value doesn't compile successfully, then the element has no compiled pattern regular expression. [ECMA262]

Constraint validation: If the element's value is not the empty string, and either the element's multiple attribute is not specified or it does not apply to the input element given its type attribute's current state, and the element has a compiled pattern regular expression but that regular expression does not match the entirety of the element's value, then the element is suffering from a pattern mismatch.

Constraint validation: If the element's value is not the empty string, and the element's multiple attribute is specified and applies to the input element, and the element has a compiled pattern regular expression but that regular expression does not match the entirety of each of the element's values, then the element is suffering from a pattern mismatch.

The compiled pattern regular expression, when matched against a string, must have its start anchored to the start of the string and its end anchored to the end of the string.

This implies that the regular expression language used for this attribute is the same as that used in JavaScript, except that the pattern attribute is matched against the entire value, not just any subset (somewhat as if it implied a ^(?: at the start of the pattern and a )$ at the end).

input芁玠が指定されたpattern属性を持぀堎合、著者は、コントロヌルの近くにパタヌンの説明を提䟛すべきである。著者は、パタヌンの説明を䞎えるためのtitle属性を含んでもよい。存圚する堎合、パタヌンが䞀臎しないこずをナヌザヌに通知する、たたはツヌルチップでたたはコントロヌルがフォヌカスを取埗する際に支揎技術によっお読み出されるなど、他の任意の適切な時点で、ナヌザヌ゚ヌゞェントは、この属性のコンテンツを䜿甚しおもよい。

title属性に䟝存するこずは、倚くのナヌザヌ゚ヌゞェントがこの仕様で芁求されるようなアクセス可胜な方法で属性を公開しないため、珟圚掚奚されないたずえば、ツヌルチップを出珟させるマりスなどのポむンティングデバむスが必芁になり、これは近代的な携垯端末やタブレットをも぀人のような、キヌボヌドのみのナヌザヌずタッチのみのナヌザヌを締め出す。

たずえば、次の断片はinputの䞋にあるテキストでパタヌンの説明を含み、パタヌン蚘述もたたtitle属性に含たれおる

<label> Part number:
        <input pattern="[0-9][A-Z]{3}" name="part"
        data-x="A part number is a digit followed by three uppercase letters."/>
        </label>
        <p>A part number is a digit followed by three uppercase letters.</p>

テキスト内のパタヌン蚘述の存圚は、デバむスにかかわらず任意のナヌザヌに利甚可胜なアドバむスを行う。

title属性でのパタヌン蚘述の存圚は、入力がフォヌカスを受ける際にスクリヌンリヌダヌのような支揎技術によっお披露されおいる説明ずなる。

ナヌザヌが誀った情報でフォヌムを送信しようずする堎合、title属性のテキストの存圚もたた、ナヌザヌ゚ヌゞェントに以䞋のような譊告を衚瀺させるかもしれない

A part number is a digit followed by three uppercase letters.
    You cannot submit this form when the field is incorrect.

この䟋においお、パタヌン蚘述はtitle属性のテキストでなく、inputの䞋のテキストである。aria-describedby属性は、明瀺的にコントロヌルず説明テキストを関連付けるために䜿甚され、inputがフォヌカスを受け取る際にスクリヌンリヌダヌなどの支揎技術によっお説明は披露される。

<label> Part number:
        <input pattern="[0-9][A-Z]{3}" name="part" aria-describedby="description">
        </label>
        <p id="description">A part number is a digit followed by three uppercase letters.</p>

コントロヌルがpattern属性を持぀堎合、titleか䜿甚された堎合、パタヌンを蚘述しなければならない。远加情報はたた、コントロヌルで埋める際にナヌザヌを支揎する限り、含たれるかもしれない。そうでなければ、支揎技術は匱められるだろう。

たずえば、title属性がコントロヌルのキャプションを含んだ堎合、支揎技術は、The text you have entered does not match the required pattern. Birthday、で終わるかもしれず、これは有益ではない。

ナヌザヌ゚ヌゞェントぱラヌ以倖の状況でたずえば、コントロヌルの䞊にマりスを移動ツヌルチップずしおtitleを䟝然ずしお衚瀺しおもよく、あたかも゚ラヌが必然的に発生しおいるかのように、著者はtitleを蚀葉で衚すこずのないよう泚意すべきである。

4.10.5.3.7 minおよびmax属性

フォヌムコントロヌルは、ナヌザヌが提䟛できる倀の蚱容範囲を制限するこずに察しお明瀺的な制玄を適甚できる。通垞、このような範囲は線圢および連続だろう。しかし、フォヌムコントロヌルの最倧限広い範囲が有限である堎合、フォヌムコントロヌルは定期的なドメむンを持぀こずができ、か぀著者は境界にたたがり、その䞭で明瀺的に範囲を指定できる。

具䜓的に、type=time制埡の広い範囲が深倜の真倜䞭24時間であり、か぀著者は䞡方の連続線圢範囲たずえば午埌9時から午埌11時たでなどや䞍連続な範囲にわたる深倜たずえば午埌11時から午前1時たでなどを蚭定できる。

minおよびmax属性は、芁玠に察しお蚱可された範囲を瀺す。

Their syntax is defined by the section that defines the type attribute's current state.

If the element has a min attribute, and the result of applying the algorithm to convert a string to a number to the value of the min attribute is a number, then that number is the element's minimum; otherwise, if the type attribute's current state defines a default minimum, then that is the minimum; otherwise, the element has no minimum.

The min attribute also defines the step base.

If the element has a max attribute, and the result of applying the algorithm to convert a string to a number to the value of the max attribute is a number, then that number is the element's maximum; otherwise, if the type attribute's current state defines a default maximum, then that is the maximum; otherwise, the element has no maximum.

芁玠が定期的なドメむンを持たない堎合、max属性の倀最倧倀は、min属性の倀最小倀未満であっおはならない。

If an element that does not have a periodic domain has a maximum that is less than its minimum, then so long as the element has a value, it will either be suffering from an underflow or suffering from an overflow.

An element has a reversed range if it has a periodic domain and its maximum is less than its minimum.

芁玠が定矩された最小倀たたは定矩された最倧倀を持぀堎合、芁玠は、範囲の制限がある。

Constraint validation: When the element has a minimum and does not have a reversed range, and the result of applying the algorithm to convert a string to a number to the string given by the element's value is a number, and the number obtained from that algorithm is less than the minimum, the element is suffering from an underflow.

Constraint validation: When the element has a maximum and does not have a reversed range, and the result of applying the algorithm to convert a string to a number to the string given by the element's value is a number, and the number obtained from that algorithm is more than the maximum, the element is suffering from an overflow.

Constraint validation: When an element has a reversed range, and the result of applying the algorithm to convert a string to a number to the string given by the element's value is a number, and the number obtained from that algorithm is more than the maximum and less than the minimum, the element is simultaneously suffering from an underflow and suffering from an overflow.

次の日付コントロヌルは1980幎代以前の日付ぞの入力を制限する

<input name=bday type=date max="1979-12-31">

次の数のコントロヌルは、れロより倧きい敎数ぞの入力を制限する

<input name=quantity required="" type="number" min="1" value="1">

真倜䞭にデフォルト蚭定、21時ず6時の間に発生した分ぞの時間管理限界入力

<input name="sleepStart" type=time min="21:00" max="06:00" step="60" value="00:00">
4.10.5.3.8 step属性

step属性は、蚱可される倀を制限するこずによっお、倀の期埅されるそしお必須の粒床を瀺す。The section that defines the type attribute's current state also defines the default step, the step scale factor, and in some cases the default step base, which are used in processing the attribute as described below.

step属性が指定される堎合、れロより倧きい数倀に解析する、劥圓な浮動小数点数である倀を持たなければならない、たたは文字列"any"ずASCII倧文字・小文字䞍区別で䞀臎する倀のいずれかを持たなければならない。

The attribute provides the allowed value step for the element, as follows:

  1. If the attribute is absent, then the allowed value step is the default step multiplied by the step scale factor.
  2. Otherwise, if the attribute's value is an ASCII case-insensitive match for the string "any", then there is no allowed value step.
  3. Otherwise, if the rules for parsing floating-point number values, when they are applied to the attribute's value, return an error, zero, or a number less than zero, then the allowed value step is the default step multiplied by the step scale factor.
  4. Otherwise, the allowed value step is the number returned by the rules for parsing floating-point number values when they are applied to the attribute's value, multiplied by the step scale factor.

The step base is the value returned by the following algorithm:

  1. If the element has a min content attribute, and the result of applying the algorithm to convert a string to a number to the value of the min content attribute is not an error, then return that result and abort these steps.

  2. If the element has a value content attribute, and the result of applying the algorithm to convert a string to a number to the value of the value content attribute is not an error, then return that result and abort these steps.

  3. If a default step base is defined for this element given its type attribute's state, then return it and abort these steps.

  4. Return zero.

Constraint validation: When the element has an allowed value step, and the result of applying the algorithm to convert a string to a number to the string given by the element's value is a number, and that number subtracted from the step base is not an integral multiple of the allowed value step, the element is suffering from a step mismatch.

次の範囲の制埡は、範囲0..1の倀のみを受け取り、その範囲内の256のステップを可胜にする

<input name=opacity type=range min=0 max=1 step=0.00392156863>

次のコントロヌルは、任意の粟床たずえば1000分の1秒粟床以䞊で、ある日においお任意の時間を遞択できる

<input name=favtime type=time step=any>

通垞、時間のコントロヌルは1分の粟床に制限される。

4.10.5.3.9 list属性

list属性は、ナヌザヌに提案枈みオプションの䞀芧を瀺す芁玠を識別するために䜿甚される。

存圚する堎合、その倀は同じ文曞でdatalist芁玠のIDでなければならない。

The suggestions source element is the first element in the document in tree order to have an ID equal to the value of the list attribute, if that element is a datalist element. If there is no list attribute, or if there is no element with that ID, or if the first element with that ID is not a datalist element, then there is no suggestions source element.

If there is a suggestions source element, then, when the user agent is allowing the user to edit the input element's value, the user agent should offer the suggestions represented by the suggestions source element to the user in a manner suitable for the type of control used. The user agent may use the suggestion's label to identify the suggestion if appropriate.

How user selections of suggestions are handled depends on whether the element is a control accepting a single value only, or whether it accepts multiple values:

If the element does not have a multiple attribute specified or if the multiple attribute does not apply

When the user selects a suggestion, the input element's value must be set to the selected suggestion's value, as if the user had written that value himself.

If the element does have a multiple attribute specified, and the multiple attribute does apply

When the user selects a suggestion, the user agent must either add a new entry to the input element's values, whose value is the selected suggestion's value, or change an existing entry in the input element's values to have the value given by the selected suggestion's value, as if the user had himself added an entry with that value, or edited an existing entry to be that value. Which behavior is to be applied depends on the user interface in a user-agent-defined manner.


If the list attribute does not apply, there is no suggestions source element.

このURLフィヌルドは、いく぀かの提案を提䟛する。

<label>Homepage: <input name=hp type=url list=hpurls></label>
<datalist id=hpurls>
 <option value="http://www.google.com/" label="Google">
 <option value="http://www.reddit.com/" label="Reddit">
</datalist>

ナヌザヌの履歎から他のURLも衚瀺されるこずがあるが、これはナヌザヌ゚ヌゞェントに任される。

この䟋は、レガシヌナヌザヌ゚ヌゞェントで䟝然ずしお劣化し぀぀有甚である、自動補完リスト機胜を䜿甚するフォヌムを蚭蚈する方法を瀺す。

自動補完リストは単なる支揎であり、コンテンツにずっお重芁でない堎合、単に子option芁玠ずずもにdatalist芁玠を䜿甚すれば十分である。レガシヌナヌザヌ゚ヌゞェントで倀をレンダリングされおるのを防止するために、これらは、むンラむンの代わりにvalue属性の内郚に配眮する必芁がある。

<p>
 <label>
  Enter a breed:
  <input type="text" name="breed" list="breeds">
  <datalist id="breeds">
   <option value="Abyssinian">
   <option value="Alpaca">
   <!-- ... -->
  </datalist>
 </label>
</p>

ただし、倀がレガシヌナヌザヌ゚ヌゞェントで瀺される必芁がある堎合、フォヌルバックコンテンツは、次のようにdatalist芁玠内に配眮できる

<p>
 <label>
  Enter a breed:
  <input type="text" name="breed" list="breeds">
 </label>
 <datalist id="breeds">
  <label>
   or select one from the list:
   <select name="breed">
    <option value=""> (none selected)
    <option>Abyssinian
    <option>Alpaca
    <!-- ... -->
   </select>
  </label>
 </datalist>
</p>

フォヌルバックコンテンツは、datalistをサポヌトしないナヌザヌ゚ヌゞェントでのみ衚瀺される。䞀方で、それらがdatalist芁玠の子ではないにもかかわらず、オプションはすべおのナヌザヌ゚ヌゞェントで怜出される。

datalistで䜿甚されるoption芁玠がselectedである堎合、芁玠はselectに圱響を䞎えるためレガシヌナヌザヌ゚ヌゞェントによっおデフォルトで遞択されるが、芁玠がdatalistをサポヌトするナヌザヌ゚ヌゞェントでinput芁玠に䜕の圱響もないこずに泚意する。

4.10.5.3.10 placeholder属性

コントロヌルが倀を持たない堎合、placeholder属性は、デヌタ入力を䌎うナヌザヌの支揎を意図する短いヒント単語や短いフレヌズを衚す。ヒントは、サンプル倀たたは期埅された圢匏の簡単な説明かもしれない。属性が指定される堎合、"LF"U+000Aたたは"CR"U+000D文字を䞀切含たない倀を持たなければならない。

placeholder属性は、labelの代替ずしお䜿甚すべきでない。ヒントや他の助蚀テキストに぀いおは、コントロヌルの次にテキストを眮く。

labelの代替ずしおのplaceholder属性の䜿甚は、高霢ナヌザヌおよび認知、モビリティヌ、埮现な運動技胜や芖芚に障害を持぀ナヌザヌを含む幅広いナヌザヌのコントロヌルのアクセシビリティヌおよびナヌザヌビリティヌを枛らすこずがある。コントロヌルのlabelによっお䞎えられるヒントは毎回衚瀺される䞀方で、placeholder属性に䞎えられた短いヒントは、ナヌザヌが倀を入力する前にのみ衚瀺される。さらに、placeholderテキストは予め埋められた倀ず間違われるかもしれず、䞀般に実装されるプレヌスホルダヌテキストのデフォルト色が䞍十分なコントラストを提䟛し、そしお別の可芖labelの欠劂は、コントロヌルのフォヌカスを蚭定するために利甚可胜なヒット領域のサむズを小さくする。

User agents should present this hint to the user, after having stripped line breaks from it, when the element's value is the empty string and the control is not focused (i.e., by displaying it inside a blank unfocused control).

ここでplaceholder属性を䜿甚するメヌル蚭定のナヌザヌむンタヌフェヌスの䟋は次のずおり

<fieldset>
 <legend>Mail Account</legend>
 <p><label>Name: <input type="text" name="fullname" placeholder="John Ratzenberger"></label></p>
 <p><label>Address: <input type="email" name="address" placeholder="john@example.net"></label></p>
 <p><label>Password: <input type="password" name="password"></label></p>
 <p><label>Description: <input type="text" name="desc" placeholder="My Email Account"></label></p>
</fieldset>

コントロヌルのコンテンツが1぀の方向性を持぀が、プレヌスホルダヌは異なる方向性を持぀必芁がある状況においお、Unicodeの双方向アルゎリズムの曞匏文字は属性倀で䜿甚できる

<input name=t1 type=tel placeholder="&#x202B; رقم Ø§Ù„هاتف 1 &#x202E;">
<input name=t2 type=tel placeholder="&#x202B; رقم Ø§Ù„هاتف 2 &#x202E;">

もう少しわかりやすくするために、むンラむンのアラビア語の代わりに数倀文字参照を䜿甚する同じ䟋を瀺す

<input name=t1 type=tel placeholder="&#x202B;&#1585;&#1602;&#1605; &#1575;&#1604;&#1607;&#1575;&#1578;&#1601; 1&#x202E;">
<input name=t2 type=tel placeholder="&#x202B;&#1585;&#1602;&#1605; &#1575;&#1604;&#1607;&#1575;&#1578;&#1601; 2&#x202E;">
4.10.5.4 共通input芁玠API
input . value [ = value ]

フォヌムコントロヌルの珟圚の倀を返す。

倀を倉曎する蚭定が可胜である。

コントロヌルがファむルアップロヌドコントロヌルである際に、空文字列以倖の任意の倀に蚭定される堎合、InvalidStateError䟋倖を投げる。

input . checked [ = value ]

フォヌムコントロヌルの珟圚checkednessを返す。

checkednessを倉曎する蚭定が可胜である。

input . files

フォヌムコントロヌルの遞択されたファむルを列挙するFileListオブゞェクトを返す。

コントロヌルがファむル制埡でない堎合はnullを返す。

input . valueAsDate [ = value ]

該圓する堎合、フォヌムのコントロヌルの倀を衚すDateオブゞェクトを返す。そうでなければ、nullを返す。

倀を倉曎する蚭定が可胜である。

コントロヌルが日付たたは時間ベヌスでない堎合、InvalidStateError䟋倖を投げる。

input . valueAsNumber [ = value ]

該圓する堎合、フォヌムのコントロヌルの倀を衚す数倀を返す。そうでなければ、NaNを返す。

倀を倉曎する蚭定が可胜である。NaNにこれを蚭定するず、空文字列の基になる倀を蚭定する。

コントロヌルが日付たたは時間ベヌスでも数倀でもない堎合、InvalidStateError䟋倖を投げる。

input . stepUp( [ n ] )
input . stepDown( [ n ] )

step属性で指定された倀によっお、フォヌムコントロヌルの倀をn倍に倉曎する。nのデフォルト倀は1である。

コントロヌルが日付たたは時間ベヌスたたは数倀のいずれでもない堎合、たたはstep属性倀が"any"である堎合、InvalidStateError䟋倖を投げる。

input . list

list属性によっお瀺されたdatalist芁玠を返す。

The value IDL attribute allows scripts to manipulate the value of an input element. The attribute is in one of the following modes, which define its behavior:

value

On getting, it must return the current value of the element. On setting, it must set the element's value to the new value, set the element's dirty value flag to true, invoke the value sanitization algorithm, if the element's type attribute's current state defines one, and then, if the element has a text entry cursor position, should move the text entry cursor position to the end of the text field, unselecting any selected text and resetting the selection direction to none.

default

On getting, if the element has a value attribute, it must return that attribute's value; otherwise, it must return the empty string. On setting, it must set the element's value attribute to the new value.

default/on

On getting, if the element has a value attribute, it must return that attribute's value; otherwise, it must return the string "on". On setting, it must set the element's value attribute to the new value.

filename

On getting, it must return the string "C:\fakepath\" followed by the name of the first file in the list of selected files, if any, or the empty string if the list is empty. On setting, if the new value is the empty string, it must empty the list of selected files; otherwise, it must throw an InvalidStateError exception.

This "fakepath" requirement is a sad accident of history. See the example in the File Upload state section for more information.


The checked IDL attribute allows scripts to manipulate the checkedness of an input element. On getting, it must return the current checkedness of the element; and on setting, it must set the element's checkedness to the new value and set the element's dirty checkedness flag to true.


The files IDL attribute allows scripts to access the element's selected files. On getting, if the IDL attribute applies, it must return a FileList object that represents the current selected files. The same object must be returned until the list of selected files changes. If the IDL attribute does not apply, then it must instead return null. [FILEAPI]


The valueAsDate IDL attribute represents the value of the element, interpreted as a date.

On getting, if the valueAsDate attribute does not apply, as defined for the input element's type attribute's current state, then return null. Otherwise, run the algorithm to convert a string to a Date object defined for that state; if the algorithm returned a Date object, then return it, otherwise, return null.

On setting, if the valueAsDate attribute does not apply, as defined for the input element's type attribute's current state, then throw an InvalidStateError exception; otherwise, if the new value is null or a Date object representing the NaN time value, then set the value of the element to the empty string; otherwise, run the algorithm to convert a Date object to a string, as defined for that state, on the new value, and set the value of the element to the resulting string.


The valueAsNumber IDL attribute represents the value of the element, interpreted as a number.

On getting, if the valueAsNumber attribute does not apply, as defined for the input element's type attribute's current state, then return a Not-a-Number (NaN) value. Otherwise, if the valueAsDate attribute applies, run the algorithm to convert a string to a Date object defined for that state; if the algorithm returned a Date object, then return the time value of the object (the number of milliseconds from midnight UTC the morning of 1970-01-01 to the time represented by the Date object), otherwise, return a Not-a-Number (NaN) value. Otherwise, run the algorithm to convert a string to a number defined for that state; if the algorithm returned a number, then return it, otherwise, return a Not-a-Number (NaN) value.

On setting, if the new value is infinite, then throw a TypeError exception. Otherwise, if the valueAsNumber attribute does not apply, as defined for the input element's type attribute's current state, then throw an InvalidStateError exception. Otherwise, if the new value is a Not-a-Number (NaN) value, then set the value of the element to the empty string. Otherwise, if the valueAsDate attribute applies, run the algorithm to convert a Date object to a string defined for that state, passing it a Date object whose time value is the new value, and set the value of the element to the resulting string. Otherwise, run the algorithm to convert a number to a string, as defined for that state, on the new value, and set the value of the element to the resulting string.


The stepDown(n) and stepUp(n) methods, when invoked, must run the following algorithm:

  1. If the stepDown() and stepUp() methods do not apply, as defined for the input element's type attribute's current state, then throw an InvalidStateError exception, and abort these steps.

  2. If the element has no allowed value step, then throw an InvalidStateError exception, and abort these steps.

  3. If the element has a minimum and a maximum and the minimum is greater than the maximum, then abort these steps.

  4. If the element has a minimum and a maximum and there is no value greater than or equal to the element's minimum and less than or equal to the element's maximum that, when subtracted from the step base, is an integral multiple of the allowed value step, then abort these steps.

  5. If applying the algorithm to convert a string to a number to the string given by the element's value does not result in an error, then let value be the result of that algorithm. Otherwise, let value be zero.

  6. If value subtracted from the step base is not an integral multiple of the allowed value step, then set value to the nearest value that, when subtracted from the step base, is an integral multiple of the allowed value step, and that is less than value if the method invoked was the stepDown() and more than value otherwise.

    Otherwise (value subtracted from the step base is an integral multiple of the allowed value step), run the following substeps:

    1. Let n be the argument.

    2. Let delta be the allowed value step multiplied by n.

    3. If the method invoked was the stepDown() method, negate delta.

    4. Let value be the result of adding delta to value.

  7. If the element has a minimum, and value is less than that minimum, then set value to the smallest value that, when subtracted from the step base, is an integral multiple of the allowed value step, and that is more than or equal to minimum.

  8. If the element has a maximum, and value is greater than that maximum, then set value to the largest value that, when subtracted from the step base, is an integral multiple of the allowed value step, and that is less than or equal to maximum.

  9. Let value as string be the result of running the algorithm to convert a number to a string, as defined for the input element's type attribute's current state, on value.

  10. Set the value of the element to value as string.


The list IDL attribute must return the current suggestions source element, if any, or null otherwise.

4.10.5.5 Common event behaviors

When the input and change events apply (which is the case for all input controls other than buttons and those with the type attribute in the Hidden state), the events are fired to indicate that the user has interacted with the control. The input event fires whenever the user has modified the data of the control. The change event fires when the value is committed, if that makes sense for the control, or else when the control loses focus. In all cases, the input event comes before the corresponding change event (if any).

When an input element has a defined activation behavior, the rules for dispatching these events, if they apply, are given in the section above that defines the type attribute's state. (This is the case for all input controls with the type attribute in the Checkbox state, the Radio Button state, or the File Upload state.)

For input elements without a defined activation behavior, but to which these events apply, and for which the user interface involves both interactive manipulation and an explicit commit action, then when the user changes the element's value, the user agent must queue a task to fire a simple event that bubbles named input at the input element, and any time the user commits the change, the user agent must queue a task to fire a simple event that bubbles named change at the input element.

An example of a user interface involving both interactive manipulation and a commit action would be a Range controls that use a slider, when manipulated using a pointing device. While the user is dragging the control's knob, input events would fire whenever the position changed, whereas the change event would only fire when the user let go of the knob, committing to a specific value.

For input elements without a defined activation behavior, but to which these events apply, and for which the user interface involves an explicit commit action but no intermediate manipulation, then any time the user commits a change to the element's value, the user agent must queue a task to first fire a simple event that bubbles named input at the input element, and then fire a simple event that bubbles named change at the input element.

An example of a user interface with a commit action would be a Color control that consists of a single button that brings up a color wheel: if the value only changes when the dialog is closed, then that would be the explicit commit action. On the other hand, if the control can be focused and manipulating the control changes the color interactively, then there might be no commit action.

Another example of a user interface with a commit action would be a Date control that allows both text-based user input and user selection from a drop-down calendar: while text input might not have an explicit commit step, selecting a date from the drop down calendar and then dismissing the drop down would be a commit action.

For input elements without a defined activation behavior, but to which these events apply, any time the user causes the element's value to change without an explicit commit action, the user agent must queue a task to fire a simple event that bubbles named input at the input element. The corresponding change event, if any, will be fired when the control loses focus.

Examples of a user changing the element's value would include the user typing into a text field, pasting a new value into the field, or undoing an edit in that field. Some user interactions do not cause changes to the value, e.g. hitting the "delete" key in an empty text field, or replacing some text in the field with text from the clipboard that happens to be exactly the same text.

A Range control in the form of a slider that the user has focused and is interacting with using a keyboard would be another example of the user changing the element's value without a commit step.

In the case of tasks that just fire an input event, user agents may wait for a suitable break in the user's interaction before queuing the tasks; for example, a user agent could wait for the user to have not hit a key for 100ms, so as to only fire the event when the user pauses, instead of continuously for each keystroke.

When the user agent is to change an input element's value on behalf of the user (e.g. as part of a form prefilling feature), the user agent must queue a task to first update the value accordingly, then fire a simple event that bubbles named input at the input element, then fire a simple event that bubbles named change at the input element.

These events are not fired in response to changes made to the values of form controls by scripts. (This is to make it easier to update the values of form controls in response to the user manipulating the controls, without having to then filter out the script's own changes to avoid an infinite loop.)

The task source for these tasks is the user interaction task source.

4.10.6 button芁玠

カテゎリ
フロヌコンテンツ。
フレヌゞングコンテンツ。
むンタラクティブコンテンツ。
蚘茉、ラベル付け可胜、送信可胜、および再関連付け可胜 フォヌム関連芁玠。
パルパブルコンテンツ。
この芁玠を䜿甚できるコンテキスト
フレヌゞングコンテンツが期埅される堎所。
コンテンツモデル
フレヌゞングコンテンツ、ただしむンタラクティブコンテンツの子孫が存圚しおはならない。
コンテンツ属性
グロヌバル属性
autofocus - ペヌゞが読み蟌たれた際にフォヌムコントロヌルに自動的にフォヌカスする
disabled - フォヌムコントロヌルが無効であるかどうか
form - form芁玠ずコントロヌルを関連付ける
formaction - フォヌム送信に䜿甚するURL
formenctype - フォヌム送信に䜿甚する文字゚ンコヌディングを蚭定するフォヌムデヌタ
formmethod - フォヌム送信に䜿甚するHTTPメ゜ッド
formnovalidate - フォヌム送信のためのフォヌムコントロヌル怜蚌を回避する
formtarget - フォヌム送信に察するブラりゞングコンテキスト
menu - 芁玠の指定されたポップアップメニュヌを指定する
name - フォヌム送信およびform.elements APIで䜿甚するフォヌムコントロヌル名
type - ボタンの皮類
value - フォヌム送信に察しお䜿甚される倀
text/htmlにおけるタグ省略
どちらのタグも省略䞍可
蚱可されるARIAロヌル属性倀
button デフォルト - 蚭定しない、link、menuitem、menuitemcheckbox、menuitemradioたたはradio。
蚱可されるARIAステヌトおよびプロパティヌ
グロヌバルaria-* 属性
蚱可されるロヌルで受け入れ可胜な任意のaria-*属性。
DOMむンタヌフェヌス
interface HTMLButtonElement : HTMLElement {
           attribute boolean autofocus;
           attribute boolean disabled;
  readonly attribute HTMLFormElement? form;
           attribute DOMString formAction;
           attribute DOMString formEnctype;
           attribute DOMString formMethod;
           attribute boolean formNoValidate;
           attribute DOMString formTarget;
           attribute DOMString name;
           attribute DOMString type;
           attribute DOMString value;

  readonly attribute boolean willValidate;
  readonly attribute ValidityState validity;
  readonly attribute DOMString validationMessage;
  boolean checkValidity();
  void setCustomValidity(DOMString error);

  readonly attribute NodeList labels;
};

button芁玠は芁玠のコンテンツによっお分類されるボタンを衚す。

芁玠はボタンである。

type属性は、アクティブ時のボタンの振る舞いを制埡する。この属性は列挙属性である。次の衚は、キヌワヌドず属性の状態を瀺す。1列目のキヌワヌドは、キヌワヌドず同じ行で2列目のセル内の状態に察応づける。

キヌワヌド 状態 抂芁
submit Submit Button フォヌムを送信する。
reset Reset Button フォヌムをリセットする。
button Button 䜕もしない。

欠損倀のデフォルトは、Submit Button状態である。

type属性がSubmit Button状態にある堎合、芁玠は具䜓的にsubmit buttonである。

Constraint validation: If the type attribute is in the Reset Button state, or the Button state, the element is barred from constraint validation.

When a button element is not disabled, its activation behavior element is to run the steps defined in the following list for the current state of the element's type attribute:

Submit Button

If the element has a form owner and the element's Document is fully active, the element must submit the form owner from the button element.

Reset Button

If the element has a form owner and the element's Document is fully active, the element must reset the form owner.

Button

䜕もしない。

form属性は、フォヌムの所有者ずbutton芁玠を明瀺的に関連付けるために䜿甚される。name属性は芁玠の名前を衚す。disabled属性は、コントロヌルが非むンタラクティブにするためおよびその倀を送信するのを防ぐために䜿甚される。autofocus属性はフォヌカスを制埡する。formaction、formenctype、formmethod、formnovalidate、formtarget属性は、フォヌム送信甚の属性である。

formnovalidate属性は、制玄怜蚌をトリガヌしない送信ボタンを䜜成するために䜿甚できる。

芁玠のtype属性がSubmit Button状態でない堎合、formaction、formenctype、formmethod、formnovalidate、formtargetは指定されおはならない。

value属性はフォヌム送信の目的のために芁玠の倀を䞎える。存圚する堎合、芁玠の倀は芁玠のvalue属性の倀であり、そうでなければ空文字列である。

ボタン自䜓がフォヌムの送信を開始するために䜿甚された堎合、ボタンおよびその倀はフォヌムの送信にのみ含たれる。


typeIDL属性は、既知の倀に制限され、同じ名前のコンテンツ属性を反映しなければならない。

The willValidate, validity, and validationMessage IDL attributes, and the checkValidity(), and setCustomValidity() methods, are part of the constraint validation API. labelsIDL属性は、 芁玠のlabelのリストを提䟛する。autofocus、disabled、form、およびnameIDL属性は芁玠のフォヌムAPIの䞀郚である。

次のボタンは、アクティブ時に、"Show hint"のラベルをもち、ダむアログボックスがポップアップ衚瀺される

<button type=button
        onclick="alert('This 15-20 minute piece was composed by George Gershwin.')">
 Show hint
</button>

4.10.7 select芁玠

カテゎリ
フロヌコンテンツ。
フレヌゞングコンテンツ。
むンタラクティブコンテンツ。
蚘茉、ラベル付け可胜、送信可胜、リセット可胜および再関連付け可胜フォヌム関連芁玠。
パルパブルコンテンツ。
この芁玠を䜿甚できるコンテキスト
フレヌゞングコンテンツが期埅される堎所。
コンテンツモデル
0個以䞊のoption、optgroup、およびスクリプトサポヌト芁玠。
コンテンツ属性
グロヌバル属性
autofocus - ペヌゞが読み蟌たれた際にフォヌムコントロヌルに自動的にフォヌカスする
disabled - フォヌムコントロヌルが無効であるかどうか
form - form芁玠ずコントロヌルを関連付ける
multiple - 耇数の倀を蚱可するかどうか
name - フォヌム送信およびform.elements APIで䜿甚するフォヌムコントロヌル名
required - コントロヌルがフォヌム送信に芁求されるかどうか
size - コントロヌルのサむズ
text/htmlにおけるタグ省略
どちらのタグも省略䞍可
蚱可されるARIAロヌル属性倀
listboxデフォルト - 蚭定しないたたはmenu。
蚱可されるARIAステヌトおよびプロパティヌ
グロヌバルaria-* 属性
蚱可されるロヌルで受け入れ可胜な任意のaria-*属性。
DOMむンタヌフェヌス
interface HTMLSelectElement : HTMLElement {
           attribute boolean autofocus;
           attribute boolean disabled;
  readonly attribute HTMLFormElement? form;
           attribute boolean multiple;
           attribute DOMString name;
           attribute boolean required;
           attribute unsigned long size;

  readonly attribute DOMString type;

  readonly attribute HTMLOptionsCollection options;
           attribute unsigned long length;
  getter Element? item(unsigned long index);
  HTMLOptionElement? namedItem(DOMString name);
  void add((HTMLOptionElement or HTMLOptGroupElement) element, optional (HTMLElement or long)? before = null);
  void remove(); // ChildNode overload
  void remove(long index);
  setter creator void (unsigned long index, HTMLOptionElement? option);

  readonly attribute HTMLCollection selectedOptions;
           attribute long selectedIndex;
           attribute DOMString value;

  readonly attribute boolean willValidate;
  readonly attribute ValidityState validity;
  readonly attribute DOMString validationMessage;
  boolean checkValidity();
  void setCustomValidity(DOMString error);

  readonly attribute NodeList labels;
};

select芁玠は、オプション䞀匏の䞭で遞択するためのコントロヌルを衚す。

multiple属性は真停属性である。属性が存圚する堎合、select芁玠は、オプションのリストから0個以䞊のオプションを遞択するためのコントロヌルを衚す。属性が存圚しない堎合、select芁玠は、オプションのリストから1぀のオプションを遞択するためのコントロヌルを衚す。

size属性は、ナヌザヌに衚瀺するためのオプションの数を䞎える。size属性が指定される堎合、0より倧きい劥圓な負でない敎数である倀を持たなければならない。

The display size of a select element is the result of applying the rules for parsing non-negative integers to the value of element's size attribute, if it has one and parsing it is successful. If applying those rules to the attribute's value is not successful, or if the size attribute is absent, then the element's display size is 4 if the element's multiple content attribute is present, and 1 otherwise.

select芁玠のオプションのリストは、ツリヌ順で、select芁玠のすべおのoption子芁玠、およびselect芁玠のすべおのoptgroup芁玠に属するすべおのoption子芁玠で構成される。

required属性は真停属性である。指定される堎合、ナヌザヌがフォヌムを送信する前に倀を遞択する必芁がある。

select芁玠がrequired属性を指定され、multiple属性を指定されず、1である衚瀺サむズを持぀堎合、およびもしあればselect芁玠のオプションのリストで最初のoptionの倀が空文字列であり、そのoption芁玠の芪ノヌドがselect芁玠か぀optgroup芁玠でない堎合、そのoptionは、select芁玠のプレヌスホルダヌのラベルオプションである。

select芁玠がrequired属性を指定され、multiple属性を指定されず、1である衚瀺サむズを持぀堎合、そのselect芁玠は、プレヌスホルダヌのラベルオプションを持たなければならない。

Constraint validation: If the element has its required attribute specified, and either none of the option elements in the select element's list of options have their selectedness set to true, or the only option element in the select element's list of options with its selectedness set to true is the placeholder label option, then the element is suffering from being missing.

If the multiple attribute is absent, and the element is not disabled, then the user agent should allow the user to pick an option element in its list of options that is itself not disabled. Upon this option element being picked (either through a click, or through unfocusing the element after changing its value, or through any other mechanism), and before the relevant user interaction event is queued (e.g. before the click event), the user agent must set the selectedness of the picked option element to true, set its dirtiness to true, and then send select update notifications.

If the multiple attribute is absent, whenever an option element in the select element's list of options has its selectedness set to true, and whenever an option element with its selectedness set to true is added to the select element's list of options, the user agent must set the selectedness of all the other option elements in its list of options to false.

If the multiple attribute is absent and the element's display size is greater than 1, then the user agent should also allow the user to request that the option whose selectedness is true, if any, be unselected. Upon this request being conveyed to the user agent, and before the relevant user interaction event is queued (e.g. before the click event), the user agent must set the selectedness of that option element to false, set its dirtiness to true, and then send select update notifications.

If nodes are inserted or nodes are removed causing the list of options to gain or lose one or more option elements, or if an option element in the list of options asks for a reset, then, if the select element's multiple attribute is absent, the select element's display size is 1, and no option elements in the select element's list of options have their selectedness set to true, the user agent must set the selectedness of the first option element in the list of options in tree order that is not disabled, if any, to true.

If the multiple attribute is present, and the element is not disabled, then the user agent should allow the user to toggle the selectedness of the option elements in its list of options that are themselves not disabled. Upon such an element being toggled (either through a click, or any other mechanism), and before the relevant user interaction event is queued (e.g. before a related click event), the selectedness of the option element must be changed (from true to false or false to true), the dirtiness of the element must be set to true, and the user agent must send select update notifications.

When the user agent is to send select update notifications, queue a task to first fire a simple event that bubbles named input at the select element, and then fire a simple event that bubbles named change at the select element, using the user interaction task source as the task source.

The reset algorithm for select elements is to go through all the option elements in the element's list of options, set their selectedness to true if the option element has a selected attribute, and false otherwise, set their dirtiness to false, and then have the option elements ask for a reset.

form属性は、フォヌムの所有者ずselect芁玠を明瀺的に関連付けるために䜿甚される。name属性は芁玠の名前を衚す。disabled属性は、コントロヌルが非むンタラクティブにするためおよびその倀を送信するのを防ぐために䜿甚される。autofocus属性はフォヌカスを制埡する。

disabledでないselect芁玠はmutableである。

select . type

芁玠がmultiple属性を持぀堎合、"select-multiple"を返し、そうでなければ"select-one"を返す。

select . options

オプションのリストのHTMLOptionsCollectionを返す。

select . length [ = value ]

オプションのリストの芁玠数を返す。

より小さい数に蚭定する堎合、selectでのoption芁玠数は切り捚おられる。

より倧きい数に蚭定する堎合、selectに新しい空癜のoption芁玠を远加する。

element = select . item(index)
select[index]

オプションのリストからのむンデックスindexずずもにアむテムを返す。アむテムはツリヌ順に゜ヌトされる。

element = select . namedItem(name)

オプションのリストからのIDたたはname nameずずもに最初のアむテムを返す。

IDをも぀芁玠が芋぀からない堎合、nullを返す。

select . add(element [, before ])

beforeによっお䞎えられるノヌドの前の芁玠を挿入する。

before匕数は数字でもよく、その堎合elementはその数字をも぀アむテムの前に挿入され、たたはオプションのリストからの芁玠でもよい。その堎合elementはその芁玠の前に挿入される。

beforeが省略された、null、たたは範囲倖の数字の堎合、elementはリストの最埌に加えられるだろう。

芁玠に挿入された芁玠が芪芁玠の堎合、このメ゜ッドはHierarchyRequestError䟋倖を投げるだろう。

select . selectedOptions

遞択されたオプションのリストのHTMLOptionsCollectionを返す。

select . selectedIndex [ = value ]

もしあるならば、最初に遞ばれたアむテムのむンデックスを、たたは遞択したアむテムが存圚しない堎合−1を返す。

遞択を倉曎する蚭定が可胜である。

select . value [ = value ]

もしあれば、最初に遞択されたアむテムの倀を返し、遞択されたアむテムが存圚しない堎合、空文字列を返す。

遞択を倉曎する蚭定が可胜である。

The type IDL attribute, on getting, must return the string "select-one" if the multiple attribute is absent, and the string "select-multiple" if the multiple attribute is present.

The options IDL attribute must return an HTMLOptionsCollection rooted at the select node, whose filter matches the elements in the list of options.

The options collection is also mirrored on the HTMLSelectElement object. The supported property indices at any instant are the indices supported by the object returned by the options attribute at that instant.

The length IDL attribute must return the number of nodes represented by the options collection. On setting, it must act like the attribute of the same name on the options collection.

The item(index) method must return the value returned by the method of the same name on the options collection, when invoked with the same argument.

The namedItem(name) method must return the value returned by the method of the same name on the options collection, when invoked with the same argument.

When the user agent is to set the value of a new indexed property for a given property index index to a new value value, it must instead set the value of a new indexed property with the given property index index to the new value value on the options collection.

Similarly, the add() method must act like its namesake method on that same options collection.

The remove() method must act like its namesake method on that same options collection when it has arguments, and like its namesake method on the ChildNode interface implemented by the HTMLSelectElement ancestor interface Element when it has no arguments.

The selectedOptions IDL attribute must return an HTMLCollection rooted at the select node, whose filter matches the elements in the list of options that have their selectedness set to true.

The selectedIndex IDL attribute, on getting, must return the index of the first option element in the list of options in tree order that has its selectedness set to true, if any. If there isn't one, then it must return −1.

On setting, the selectedIndex attribute must set the selectedness of all the option elements in the list of options to false, and then the option element in the list of options whose index is the given new value, if any, must have its selectedness set to true and its dirtiness set to true.

This can result in no element having a selectedness set to true even in the case of the select element having no multiple attribute and a display size of 1.

The value IDL attribute, on getting, must return the value of the first option element in the list of options in tree order that has its selectedness set to true, if any. If there isn't one, then it must return the empty string.

On setting, the value attribute must set the selectedness of all the option elements in the list of options to false, and then the first option element in the list of options, in tree order, whose value is equal to the given new value, if any, must have its selectedness set to true and its dirtiness set to true.

This can result in no element having a selectedness set to true even in the case of the select element having no multiple attribute and a display size of 1.

The multiple, required, and size IDL attributes must reflect the respective content attributes of the same name. The size IDL attribute has a default value of zero.

For historical reasons, the default value of the size IDL attribute does not return the actual size used, which, in the absence of the size content attribute, is either 1 or 4 depending on the presence of the multiple attribute.

The willValidate, validity, and validationMessage IDL attributes, and the checkValidity(), and setCustomValidity() methods, are part of the constraint validation API. labelsIDL属性は、 芁玠のlabelのリストを提䟛する。autofocus、disabled、form、およびnameIDL属性は芁玠のフォヌムAPIの䞀郚である。

オプションのセットからナヌザヌが1぀のオプションを遞択できるselect芁玠が䜿甚される様子を次に瀺す。デフォルトのオプションはあらかじめ遞択されおいる。

<p>
 <label for="unittype">Select unit type:</label>
 <select id="unittype" name="unittype">
  <option value="1"> Miner </option>
  <option value="2"> Puffer </option>
  <option value="3" selected> Snipey </option>
  <option value="4"> Max </option>
  <option value="5"> Firebot </option>
 </select>
</p>

デフォルトのオプションが存圚しない堎合、プレヌスホルダヌが代わりに䜿甚される

<select name="unittype" required>
 <option value=""> Select unit type </option>
 <option value="1"> Miner </option>
 <option value="2"> Puffer </option>
 <option value="3"> Snipey </option>
 <option value="4"> Max </option>
 <option value="5"> Firebot </option>
</select>

ここでは、ナヌザヌがオプションのセットから任意の数を遞択できる。デフォルトで、5぀すべおのオプションが遞択されおいる。

<p>
 <label for="allowedunits">Select unit types to enable on this map:</label>
 <select id="allowedunits" name="allowedunits" multiple>
  <option value="1" selected> Miner </option>
  <option value="2" selected> Puffer </option>
  <option value="3" selected> Snipey </option>
  <option value="4" selected> Max </option>
  <option value="5" selected> Firebot </option>
 </select>
</p>

ずきには、ナヌザヌは1぀以䞊の項目を遞択する必芁がある。次の䟋はそのようなむンタヌフェヌスを瀺す。

<p>Select the songs from that you would like on your Act II Mix Tape:</p>
<select multiple required name="act2">
 <option value="s1">It Sucks to Be Me (Reprise)
 <option value="s2">There is Life Outside Your Apartment
 <option value="s3">The More You Ruv Someone
 <option value="s4">Schadenfreude
 <option value="s5">I Wish I Could Go Back to College
 <option value="s6">The Money Song
 <option value="s7">School for Monsters
 <option value="s8">The Money Song (Reprise)
 <option value="s9">There's a Fine, Fine Line (Reprise)
 <option value="s10">What Do You Do With a B.A. in English? (Reprise)
 <option value="s11">For Now
</select>

4.10.8 datalist芁玠

カテゎリ
フロヌコンテンツ。
フレヌゞングコンテンツ。
この芁玠を䜿甚できるコンテキスト
フレヌゞングコンテンツが期埅される堎所。
コンテンツモデル
以䞋のいずれか0個以䞊のoption芁玠子孫をも぀フレヌゞングコンテンツ。
たたは0個以䞊のoption芁玠。
コンテンツ属性
グロヌバル属性
text/htmlにおけるタグ省略
どちらのタグも省略䞍可
蚱可されるARIAロヌル属性倀
listbox デフォルト - 蚭定しない。
蚱可されるARIAステヌトおよびプロパティヌ
グロヌバルaria-* 属性
蚱可されるロヌルで受け入れ可胜な任意のaria-*属性。
DOMむンタヌフェヌス
interface HTMLDataListElement : HTMLElement {
  readonly attribute HTMLCollection options;
};

datalist芁玠は、他のコントロヌル甚にあらかじめ定矩されたオプションを衚すoption芁玠のセットを衚す。In the rendering, the datalist element represents nothing and it, along with its children, should be hidden.

datalist芁玠は2぀の方法で䜿甚される。最も単玔な堎合、datalist芁玠はoption芁玠の子のみを持぀。

<label>
 Sex:
 <input name=sex list=sexes>
 <datalist id=sexes>
  <option value="Female">
  <option value="Male">
 </datalist>
</label>

より手の蟌んだ堎合、datalist芁玠はdatalistをサポヌトしないダりンレベルクラむアントに察しお衚瀺されるコンテンツを䞎えられる。この堎合、option芁玠はdatalist芁玠の内偎のselect芁玠の内偎で提䟛される。

<label>
 Sex:
 <input name=sex list=sexes>
</label>
<datalist id=sexes>
 <label>
  or select from the list:
  <select name=sex>
   <option value="">
   <option>Female
   <option>Male
  </select>
 </label>
</datalist>

datalist芁玠はinput芁玠でlist属性を䜿甚するinput芁玠に接続される。

その倀が空文字列でない文字列である、無効でない、datalist芁玠の子孫である各option芁玠は、提案を衚す。各提案は、倀ずラベルを持぀。

datalist . options

datalistのoptions芁玠のHTMLCollectionを返す。

The options IDL attribute must return an HTMLCollection rooted at the datalist node, whose filter matches option elements.

Constraint validation: If an element has a datalist element ancestor, it is barred from constraint validation.

4.10.9 optgroup芁玠

カテゎリ
なし。
この芁玠を䜿甚できるコンテキスト
select芁玠の子ずしお。
コンテンツモデル
0個以䞊のoptionおよびスクリプトサポヌト芁玠。
コンテンツ属性
グロヌバル属性
disabled - フォヌムコントロヌルが無効であるかどうか
label - ナヌザヌ可芖ラベル
text/htmlにおけるタグ省略
An optgroup element's end tag may be omitted if the optgroup element is immediately followed by another optgroup element, or if there is no more content in the parent element.
蚱可されるARIAロヌル属性倀
なし
蚱可されるARIAステヌトおよびプロパティヌ
グロヌバルaria-* 属性
DOMむンタヌフェヌス
interface HTMLOptGroupElement : HTMLElement {
           attribute boolean disabled;
           attribute DOMString label;
};

optgroup芁玠は、共通のラベルをも぀option芁玠のグルヌプを衚す。

option芁玠の芁玠のグルヌプは、optgroup芁玠の子であるoption芁玠で構成する。

When showing option elements in select elements, user agents should show the option elements of such groups as being related to each other and separate from other option elements.

disabled属性は真停属性であり、䞀緒にoption芁玠のグルヌプを無効にするために䜿甚できる。

label属性を指定しなければならない。その倀は、ナヌザヌむンタヌフェヌスの目的に察しお、グルヌプの名前を䞎える。User agents should use this attribute's value when labeling the group of option elements in a select element.

The disabled and label attributes must reflect the respective content attributes of the same name.

次の断片は、selectドロップダりンりィゞェットで3぀のコヌスからレッスンのセットが提䟛される様子を瀺す

<form action="courseselector.dll" method="get">
 <p>Which course would you like to watch today?
 <p><label>Course:
  <select name="c">
   <optgroup label="8.01 Physics I: Classical Mechanics">
    <option value="8.01.1">Lecture 01: Powers of Ten
    <option value="8.01.2">Lecture 02: 1D Kinematics
    <option value="8.01.3">Lecture 03: Vectors
   <optgroup label="8.02 Electricity and Magnestism">
    <option value="8.02.1">Lecture 01: What holds our world together?
    <option value="8.02.2">Lecture 02: Electric Field
    <option value="8.02.3">Lecture 03: Electric Flux
   <optgroup label="8.03 Physics III: Vibrations and Waves">
    <option value="8.03.1">Lecture 01: Periodic Phenomenon
    <option value="8.03.2">Lecture 02: Beats
    <option value="8.03.3">Lecture 03: Forced Oscillations with Damping
  </select>
 </label>
 <p><input type=submit value="▶ Play">
</form>

4.10.10 option芁玠

カテゎリ
なし。
この芁玠を䜿甚できるコンテキスト
select芁玠の子ずしお。
datalist芁玠の子ずしお。
optgroup芁玠の子ずしお。
コンテンツモデル
芁玠がlabel属性およびvalue属性を持぀堎合空。
芁玠がlabel属性を持぀がvalue属性を持たない堎合テキスト。
芁玠がlabel属性を持たない堎合芁玠内の空癜文字でないテキスト。
コンテンツ属性
グロヌバル属性
disabled - フォヌムコントロヌルが無効であるかどうか
label - ナヌザヌ可芖ラベル
selected - デフォルトでオプションが遞択されるかどうか
value - フォヌム送信に察しお䜿甚される倀
text/htmlにおけるタグ省略
option芁玠が別のoption芁玠たたはoptgroup芁玠の盎前に存圚する堎合、たたは芪芁玠に远加のコンテンツが存圚しない堎合、option芁玠の終了タグは省略しおもよい。
蚱可されるARIAロヌル属性倀
optionデフォルト - 蚭定しない、menuitem、menuitemradioたたはseparator。
蚱可されるARIAステヌトおよびプロパティヌ
グロヌバルaria-* 属性
蚱可されるロヌルで受け入れ可胜な任意のaria-*属性。
DOMむンタヌフェヌス
[NamedConstructor=Option(optional DOMString text = "", optional DOMString value, optional boolean defaultSelected = false, optional boolean selected = false)]
interface HTMLOptionElement : HTMLElement {
           attribute boolean disabled;
  readonly attribute HTMLFormElement? form;
           attribute DOMString label;
           attribute boolean defaultSelected;
           attribute boolean selected;
           attribute DOMString value;

           attribute DOMString text;
  readonly attribute long index;
};

option芁玠は、select芁玠でたたはdatalist芁玠で提案のリストの䞀郚ずしおオプションを衚す。

selectの定矩で蚘茉されるある特定の状況においお、option芁玠は、select芁玠のプレヌスホルダヌのラベルオプションずなるこずができる。プレヌスホルダヌのラベルオプションは、実際のオプションを衚さないが、selectコントロヌルのラベルを衚す。

disabled属性は、真停属性である。芁玠のdisabled属性が存圚する堎合、たたはdisabled属性であるoptgroup芁玠の子が存圚する堎合、option芁玠は無効である。

An option element that is disabled must prevent any click events that are queued on the user interaction task source from being dispatched on the element.

label属性は、芁玠のラベルを提䟛する。属性が存圚する堎合、optionのラベルはlabelコンテンツ属性の倀であり、存圚しない堎合、芁玠のtext IDL属性の倀ずなる。

labelコンテンツ属性が指定される堎合、空であっおはならない。

value属性は、その芁玠の倀を提䟛する。属性が存圚する堎合、optionの倀はvalueコンテンツ属性の倀であり、存圚しない堎合、芁玠のtext IDL属性の倀ずなる。

selected属性は、真停属性である。これは、芁玠のデフォルトselectednessを衚す。

The dirtiness of an option element is a boolean state, initially false. It controls whether adding or removing the selected content attribute has any effect.

The selectedness of an option element is a boolean state, initially false. Except where otherwise specified, when the element is created, its selectedness must be set to true if the element has a selected attribute. Whenever an option element's selected attribute is added, if its dirtiness is false, its selectedness must be set to true. Whenever an option element's selected attribute is removed, if its dirtiness is false, its selectedness must be set to false.

The Option() constructor, when called with three or fewer arguments, overrides the initial state of the selectedness state to always be false even if the third argument is true (implying that a selected attribute is to be set). The fourth argument can be used to explicitly set the initial selectedness state when using the constructor.

multiple属性が指定されないselect芁玠は、そのselected属性蚭定を持぀耇数の子孫option芁玠を持っおはならない。

An option element's index is the number of option elements that are in the same list of options but that come before it in tree order. If the option element is not in a list of options, then the option element's index is zero.

option . selected

芁玠が遞択される堎合trueを返し、そうでなければfalseを返す。

芁玠の珟圚の状態を䞊曞きする蚭定が可胜である。

option . index

そのselect芁玠のoptionsリストで芁玠のむンデックスを返す。

option . form

存圚するならば、芁玠のform芁玠を返し、たたはそうでなければnullを返す。

option . text

スペヌスが盞殺されscript芁玠がスキップされる堎合を陀き、textContentず同じ。

option = new Option( [ text [, value [, defaultSelected [, selected ] ] ] ] )

新しいoption芁玠を返す。

text匕数は芁玠のコンテンツを蚭定する。

value匕数はvalue属性を蚭定する。

defaultSelected匕数はselected属性を蚭定する。

selected匕数は芁玠が遞択されるかどうかを蚭定する。省略される堎合、たずえdefaultSelected匕数がtrueであっおも、芁玠は遞択されない。

The disabled IDL attribute must reflect the content attribute of the same name. The defaultSelected IDL attribute must reflect the selected content attribute.

The label IDL attribute, on getting, must return the element's label. On setting, the element's label content attribute must be set to the new value.

The value IDL attribute, on getting, must return the element's value. On setting, the element's value content attribute must be set to the new value.

The selected IDL attribute, on getting, must return true if the element's selectedness is true, and false otherwise. On setting, it must set the element's selectedness to the new value, set its dirtiness to true, and then cause the element to ask for a reset.

The index IDL attribute must return the element's index.

The text IDL attribute, on getting, must return the result of stripping and collapsing whitespace from the concatenation of data of all the Text node descendants of the option element, in tree order, excluding any that are descendants of descendants of the option element that are themselves script elements in the HTML namespace or script elements in the SVG namespace.

On setting, the text attribute must act as if the textContent IDL attribute on the element had been set to the new value.

The form IDL attribute's behavior depends on whether the option element is in a select element or not. If the option has a select element as its parent, or has an optgroup element as its parent and that optgroup element has a select element as its parent, then the form IDL attribute must return the same value as the form IDL attribute on that select element. Otherwise, it must return null.

A constructor is provided for creating HTMLOptionElement objects (in addition to the factory methods from DOM such as createElement()): Option(text, value, defaultSelected, selected). When invoked as a constructor, it must return a new HTMLOptionElement object (a new option element). If the first argument is not the empty string, the new object must have as its only child a Text node whose data is the value of that argument. Otherwise, it must have no children. If the value argument is present, the new object must have a value attribute set with the value of the argument as its value. If the defaultSelected argument is true, the new object must have a selected attribute set with no value. If the selected argument is true, the new object must have its selectedness set to true; otherwise the selectedness must be set to false, even if the defaultSelected argument is true. The element's document must be the active document of the browsing context of the Window object on which the interface object of the invoked constructor is found.

4.10.11 textarea芁玠

カテゎリ
フロヌコンテンツ。
フレヌゞングコンテンツ。
むンタラクティブコンテンツ。
蚘茉、ラベル付け可胜、送信可胜、リセット可胜および再関連付け可胜フォヌム関連芁玠。
パルパブルコンテンツ。
この芁玠を䜿甚できるコンテキスト
フレヌゞングコンテンツが期埅される堎所。
コンテンツモデル
Text。
コンテンツ属性
グロヌバル属性
autocomplete - フォヌムオヌトフィル機胜に察するヒント
autofocus - ペヌゞが読み蟌たれた際にフォヌムコントロヌルに自動的にフォヌカスする
cols - 行あたりの最倧文字数
dirname - フォヌム送信で、芁玠の方向を送信するために䜿甚するフォヌムフィヌルドの名前
disabled - フォヌムコントロヌルが無効であるかどうか
form - form芁玠ずコントロヌルを関連付ける
inputmode - 入力モダリティヌを遞択するためのヒント
maxlength - 倀の最倧長さ
minlength - 倀の最小長さ
name - フォヌム送信およびform.elements APIで䜿甚するフォヌムコントロヌル名
placeholder - フォヌムコントロヌル内に配眮されるナヌザヌ可芖ラベル
readonly - ナヌザヌによっお線集される倀を蚱可するかどうか
required - コントロヌルがフォヌム送信に芁求されるかどうか
rows - 衚瀺する行数
wrap - どのようにフォヌムコントロヌル倀がフォヌム送信に察しお包たれるか
text/htmlにおけるタグ省略
どちらのタグも省略䞍可
蚱可されるARIAロヌル属性倀
textbox デフォルト - 蚭定しない。
蚱可されるARIAステヌトおよびプロパティヌ
グロヌバルaria-* 属性
蚱可されるロヌルで受け入れ可胜な任意のaria-*属性。
DOMむンタヌフェヌス
interface HTMLTextAreaElement : HTMLElement {
           attribute DOMString autocomplete;
           attribute boolean autofocus;
           attribute unsigned long cols;
           attribute DOMString dirName;
           attribute boolean disabled;
  readonly attribute HTMLFormElement? form;
           attribute long maxLength;
           attribute long minLength;
           attribute DOMString name;
           attribute DOMString placeholder;
           attribute boolean readOnly;
           attribute boolean required;
           attribute unsigned long rows;
           attribute DOMString wrap;

  readonly attribute DOMString type;
           attribute DOMString defaultValue;
  [TreatNullAs=EmptyString] attribute DOMString value;
  readonly attribute unsigned long textLength;

  readonly attribute boolean willValidate;
  readonly attribute ValidityState validity;
  readonly attribute DOMString validationMessage;
  boolean checkValidity();
  void setCustomValidity(DOMString error);

  readonly attribute NodeList labels;

  void select();
           attribute unsigned long selectionStart;
           attribute unsigned long selectionEnd;
           attribute DOMString selectionDirection;
  void setRangeText(DOMString replacement);
  void setRangeText(DOMString replacement, unsigned long start, unsigned long end, optional SelectionMode selectionMode = "preserve");
  void setSelectionRange(unsigned long start, unsigned long end, optional DOMString direction);
};

The textarea element represents a multiline plain text edit control for the element's raw value. コントロヌルのコンテンツは、コントロヌルのデフォルトの倀を衚す。

The raw value of a textarea control must be initially the empty string.

This element has rendering requirements involving the bidirectional algorithm.

readonly属性は、テキストがナヌザヌによっお線集できるかどうかを制埡するために䜿甚される真停属性である。

この䟋においお、テキストフィヌルドは読み取り専甚ファむルを衚すので、読み取り専甚ずしおマヌクされる

Filename: <code>/etc/bash.bashrc</code>
<textarea name="buffer" readonly>
# System-wide .bashrc file for interactive bash(1) shells.

# To enable the settings / commands in this file for login shells as well,
# this file has to be sourced in /etc/profile.

# If not running interactively, don't do anything
[ -z "$PS1" ] &amp;&amp; return

...</textarea>

Constraint validation: If the readonly attribute is specified on a textarea element, the element is barred from constraint validation.

A textarea element is mutable if it is neither disabled nor has a readonly attribute specified.

When a textarea is mutable, its raw value should be editable by the user: the user agent should allow the user to edit, insert, and remove text, and to insert and remove line breaks in the form of "LF" (U+000A) characters. Any time the user causes the element's raw value to change, the user agent must queue a task to fire a simple event that bubbles named input at the textarea element. User agents may wait for a suitable break in the user's interaction before queuing the task; for example, a user agent could wait for the user to have not hit a key for 100ms, so as to only fire the event when the user pauses, instead of continuously for each keystroke.

A textarea element has a dirty value flag, which must be initially set to false, and must be set to true whenever the user interacts with the control in a way that changes the raw value.

When the textarea element's textContent IDL attribute changes value, if the element's dirty value flag is false, then the element's raw value must be set to the value of the element's textContent IDL attribute.

The reset algorithm for textarea elements is to set the element's value to the value of the element's textContent IDL attribute.

If the element is mutable, the user agent should allow the user to change the writing direction of the element, setting it either to a left-to-right writing direction or a right-to-left writing direction. If the user does so, the user agent must then run the following steps:

  1. Set the element's dir attribute to "ltr" if the user selected a left-to-right writing direction, and "rtl" if the user selected a right-to-left writing direction.

  2. Queue a task to fire a simple event that bubbles named input at the textarea element.

cols属性は行あたりの予想最倧文字数を指定する。cols属性が指定される堎合、その倀は0より倧きい劥圓な非負敎数でなければならない。If applying the rules for parsing non-negative integers to the attribute's value results in a number greater than zero, then the element's character width is that value; otherwise, it is 20.

The user agent may use the textarea element's character width as a hint to the user as to how many characters the server prefers per line (e.g. for visual user agents by making the width of the control be that many characters). In visual renderings, the user agent should wrap the user's input in the rendering so that each line is no wider than this number of characters.

rows属性は、衚瀺する行数を指定する。rows属性が指定される堎合、その倀は0より倧きい劥圓な非負敎数でなければならない。If applying the rules for parsing non-negative integers to the attribute's value results in a number greater than zero, then the element's character height is that value; otherwise, it is 2.

Visual user agents should set the height of the control to the number of lines given by character height.

wrap属性は、2぀のキヌワヌドず状態をも぀真停属性である。softキヌワヌドはSoft状態に察応し、hardキヌワヌドはHard状態に察応する。欠損倀のデフォルトは、Soft状態である。

Soft状態は、テキストが送信される際、レンダリングにおいおテキストが䟝然ずしお包たれるこずはできるがtextareaでテキストが包たれないこずを瀺す。

Hard状態は、textareaでテキストがナヌザヌ゚ヌゞェントによっお远加される改行を持぀ので、テキストが送信される際にテキストが包たれるこずを瀺す。

芁玠のwrap属性がHard状態にある堎合、cols属性を指定しなければならない。

For historical reasons, the element's value is normalised in three different ways for three different purposes. The raw value is the value as it was originally set. It is not normalized. The API value is the value used in the value IDL attribute. It is normalized so that line breaks use "LF" (U+000A) characters. Finally, there is the form submission value. It is normalized so that line breaks use U+000D CARRIAGE RETURN "CRLF" (U+000A) character pairs, and in addition, if necessary given the element's wrap attribute, additional line breaks are inserted to wrap the text at the given width.

The element's API value is defined to be the element's raw value with the following transformation applied:

  1. Replace every U+000D CARRIAGE RETURN "CRLF" (U+000A) character pair from the raw value with a single "LF" (U+000A) character.

  2. Replace every remaining U+000D CARRIAGE RETURN character from the raw value with a single "LF" (U+000A) character.

The element's value is defined to be the element's raw value with the following transformation applied:

  1. Replace every occurrence of a "CR" (U+000D) character not followed by a "LF" (U+000A) character, and every occurrence of a "LF" (U+000A) character not preceded by a "CR" (U+000D) character, by a two-character string consisting of a U+000D CARRIAGE RETURN "CRLF" (U+000A) character pair.

  2. If the element's wrap attribute is in the Hard state, insert U+000D CARRIAGE RETURN "CRLF" (U+000A) character pairs into the string using a UA-defined algorithm so that each line has no more than character width characters. For the purposes of this requirement, lines are delimited by the start of the string, the end of the string, and U+000D CARRIAGE RETURN "CRLF" (U+000A) character pairs.

maxlength属性は、textarea芁玠の汚い倀フラグによっお制埡されるフォヌムコントロヌルmaxlength属性である。

textarea芁玠が最倧蚱容倀の長さを持぀堎合、その芁玠の子は、芁玠のtextContentIDL属性倀に属するコヌド単䜍の長さに等しいか、たたは芁玠の最倧蚱容倀の長さよりも小さくなるようにしなければならない。

minlength属性は、textarea芁玠の汚い倀フラグによっお制埡されるフォヌムコントロヌルminlength属性である。

required属性は真停属性である。指定される堎合、ナヌザヌがフォヌムを送信する前に倀を入力する必芁がある。

Constraint validation: If the element has its required attribute specified, and the element is mutable, and the element's value is the empty string, then the element is suffering from being missing.

コントロヌルが倀を持たない堎合、placeholder属性は、デヌタ入力を䌎うナヌザヌの支揎を意図する短いヒント単語や短いフレヌズを衚す。ヒントは、サンプル倀たたは期埅された圢匏の簡単な説明かもしれない。

placeholder属性は、labelの代替ずしお䜿甚すべきでない。ヒントや他の助蚀テキストに぀いおは、コントロヌルの次にテキストを眮く。

labelの代替ずしおのplaceholder属性の䜿甚は、高霢ナヌザヌおよび認知、モビリティヌ、埮现な運動技胜や芖芚に障害を持぀ナヌザヌを含む幅広いナヌザヌのコントロヌルのアクセシビリティヌおよびナヌザヌビリティヌを枛らすこずがある。コントロヌルのlabelによっお䞎えられるヒントは毎回衚瀺される䞀方で、placeholder属性に䞎えられた短いヒントは、ナヌザヌが倀を入力する前にのみ衚瀺される。さらに、placeholderテキストは予め埋められた倀ず間違われるかもしれず、䞀般に実装されるプレヌスホルダヌテキストのデフォルト色が䞍十分なコントラストを提䟛し、そしお別の可芖labelの欠劂は、コントロヌルのフォヌカスを蚭定するために利甚可胜なヒット領域のサむズを小さくする。

User agents should present this hint to the user when the element's value is the empty string and the control is not focused (e.g. by displaying it inside a blank unfocused control). All U+000D CARRIAGE RETURN U+000A LINE FEED character pairs (CRLF) in the hint, as well as all other "CR" (U+000D) and "LF" (U+000A) characters in the hint, must be treated as line breaks when rendering the hint.

name属性は芁玠の名前を衚す。dirname属性は、芁玠の方向がどのように送信されるかを制埡する。disabled属性は、コントロヌルが非むンタラクティブにするためおよびその倀を送信するのを防ぐために䜿甚される。form属性は、フォヌム所有者ずtextarea芁玠を明瀺的に関連付けるために䜿甚される。autofocus属性はフォヌカスを制埡する。autocomplete属性は、どのようにナヌザヌ゚ヌゞェントがオヌトフィルの振る舞いを提䟛するかを制埡する。

textarea . type

文字列"textarea"を返す。

textarea . value

芁玠の珟圚の倀を返す。

倀を倉曎する蚭定が可胜である。

The cols, placeholder, required, rows, and wrap attributes must reflect the respective content attributes of the same name. The cols and rows attributes are limited to only non-negative numbers greater than zero. The cols attribute's default value is 20. The rows attribute's default value is 2. The dirName IDL attribute must reflect the dirname content attribute. The maxLength IDL attribute must reflect the maxlength content attribute, limited to only non-negative numbers. The minLength IDL attribute must reflect the minlength content attribute, limited to only non-negative numbers. The readOnly IDL attribute must reflect the readonly content attribute.

The type IDL attribute must return the value "textarea".

The defaultValue IDL attribute must act like the element's textContent IDL attribute.

The value attribute must, on getting, return the element's API value; on setting, it must set the element's raw value to the new value, set the element's dirty value flag to true, and should then move the text entry cursor position to the end of the text field, unselecting any selected text and resetting the selection direction to none.

The textLength IDL attribute must return the code-unit length of the element's API value.

The willValidate, validity, and validationMessage IDL attributes, and the checkValidity(), and setCustomValidity() methods, are part of the constraint validation API. labelsIDL属性は、 芁玠のlabelのリストを提䟛する。The select(), selectionStart, selectionEnd, selectionDirection, setRangeText(), and setSelectionRange() methods and IDL attributes expose the element's text selection. The autofocus, disabled, form, and name IDL attributes are part of the element's forms API.

ここで、フォヌムで無制限の自由圢匏のテキスト入力に察しお䜿甚されるtextareaの䟋は次のずおり

<p>If you have any comments, please let us know: <textarea cols=80 name=comments></textarea></p>

コメントの最倧長を指定するために、maxlength属性を䜿甚できる

<p>If you have any short comments, please let us know: <textarea cols=80 name=comments maxlength=200></textarea></p>

デフォルト倀を䞎えるために、テキストを芁玠内に含むこずができる

<p>If you have any comments, please let us know: <textarea cols=80 name=comments>You rock!</textarea></p>

たた、最小の長さを䞎えるこずもできる。ここで、文字はナヌザヌによっお蚘入される必芁がある。テンプレヌトこれは最小の長さよりも短くなっおいるが蚭けられおいるが、フォヌムを送信するには䞍十分である。

<textarea required minlength="500">Dear Madam Speaker,

Regarding your letter dated ...

...

Yours Sincerely,

...</textarea>

プレヌスホルダヌは明瀺的なテンプレヌトを提䟛するこずなく、ナヌザヌぞの基本的な圢を提案するために同様に䞎えるこずができる。

<textarea placeholder="Dear Francine,

They closed the parks this week, so we won't be able to
meet your there. Should we just have dinner?

Love,
Daddy"></textarea>

ブラりザが倀ずずもに芁玠の方向を送信させる堎合、dirnameに属性を指定できる

<p>If you have any comments, please let us know (you may use either English or Hebrew for your comments):
<textarea cols=80 name=comments dirname=comments.dir></textarea></p>

4.10.12 keygen芁玠

カテゎリ
フロヌコンテンツ。
フレヌゞングコンテンツ。
むンタラクティブコンテンツ。
蚘茉、ラベル付け可胜、送信可胜、リセット可胜および再関連付け可胜フォヌム関連芁玠。
パルパブルコンテンツ。
この芁玠を䜿甚できるコンテキスト
フレヌゞングコンテンツが期埅される堎所。
コンテンツモデル
空。
コンテンツ属性
グロヌバル属性
autofocus - ペヌゞが読み蟌たれた際にフォヌムコントロヌルに自動的にフォヌカスする
challenge - 生成され眲名される公開鍵ずずもにパッケヌゞ化する文字列
disabled - フォヌムコントロヌルが無効であるかどうか
form - form芁玠ずコントロヌルを関連付ける
keytype - 生成する暗号鍵の皮類
name - フォヌム送信およびform.elements APIで䜿甚するフォヌムコントロヌル名
text/htmlにおけるタグ省略
終了タグなし。
蚱可されるARIAロヌル属性倀
なし
蚱可されるARIAステヌトおよびプロパティヌ
グロヌバルaria-* 属性
DOMむンタヌフェヌス
interface HTMLKeygenElement : HTMLElement {
           attribute boolean autofocus;
           attribute DOMString challenge;
           attribute boolean disabled;
  readonly attribute HTMLFormElement? form;
           attribute DOMString keytype;
           attribute DOMString name;

  readonly attribute DOMString type;

  readonly attribute boolean willValidate;
  readonly attribute ValidityState validity;
  readonly attribute DOMString validationMessage;
  boolean checkValidity();
  void setCustomValidity(DOMString error);

  readonly attribute NodeList labels;
};

keygen芁玠は、鍵ペアゞェネレヌタヌコントロヌルを衚す。コントロヌルのフォヌムが送信されるず、秘密鍵はロヌカルキヌストアに保存され、公開鍵はパッケヌゞ化されおサヌバに送信される。

challenge属性を指定しおもよい。その倀は送信鍵ず䞀緒にパッケヌゞにされる。

keytype属性は、列挙属性である。次の衚は、キヌワヌドず属性の状態を瀺す。1列目のキヌワヌドは、キヌワヌドず同じ行で2列目のセル内の状態に察応づける。ナヌザヌ゚ヌゞェントは、これらの倀をサポヌトする必芁はないが、サポヌトするアルゎリズムに察応する倀を単に認識しなければならない。

キヌワヌド 状態
rsa RSA

無効倀のデフォルトは、unknown状態である。サポヌトされる堎合、欠損倀のデフォルトはRSA状態であり、そうでなければunknown状態である。

この仕様は、ナヌザヌ゚ヌゞェントがサポヌトすべき鍵の皮類を指定しない―ナヌザヌ゚ヌゞェントが鍵の皮類をたったくサポヌトしないこずも可胜である。

The user agent may expose a user interface for each keygen element to allow the user to configure settings of the element's key pair generator, e.g. the key length.

The reset algorithm for keygen elements is to set these various configuration settings back to their defaults.

The element's value is the string returned from the following algorithm:

  1. Use the appropriate step from the following list:

    If the keytype attribute is in the RSA state

    Generate an RSA key pair using the settings given by the user, if appropriate, using the md5WithRSAEncryption RSA signature algorithm (the signature algorithm with MD5 and the RSA encryption algorithm) referenced in section 2.2.1 ("RSA Signature Algorithm") of RFC 3279, and defined in RFC 3447. [RFC3279] [RFC3447]

    Otherwise, the keytype attribute is in the unknown state

    The given key type is not supported. Return the empty string and abort this algorithm.

    Let private key be the generated private key.

    Let public key be the generated public key.

    Let signature algorithm be the selected signature algorithm.

  2. If the element has a challenge attribute, then let challenge be that attribute's value. Otherwise, let challenge be the empty string.

  3. Let algorithm be an ASN.1 AlgorithmIdentifier structure as defined by RFC 5280, with the algorithm field giving the ASN.1 OID used to identify signature algorithm, using the OIDs defined in section 2.2 ("Signature Algorithms") of RFC 3279, and the parameters field set up as required by RFC 3279 for AlgorithmIdentifier structures for that algorithm. [X690] [RFC5280] [RFC3279]

  4. Let spki be an ASN.1 SubjectPublicKeyInfo structure as defined by RFC 5280, with the algorithm field set to the algorithm structure from the previous step, and the subjectPublicKey field set to the BIT STRING value resulting from ASN.1 DER encoding the public key. [X690] [RFC5280]

  5. Let publicKeyAndChallenge be an ASN.1 PublicKeyAndChallenge structure as defined below, with the spki field set to the spki structure from the previous step, and the challenge field set to the string challenge obtained earlier. [X690]

  6. Let signature be the BIT STRING value resulting from ASN.1 DER encoding the signature generated by applying the signature algorithm to the byte string obtained by ASN.1 DER encoding the publicKeyAndChallenge structure, using private key as the signing key. [X690]

  7. Let signedPublicKeyAndChallenge be an ASN.1 SignedPublicKeyAndChallenge structure as defined below, with the publicKeyAndChallenge field set to the publicKeyAndChallenge structure, the signatureAlgorithm field set to the algorithm structure, and the signature field set to the BIT STRING signature from the previous step. [X690]

  8. Return the result of base64 encoding the result of ASN.1 DER encoding the signedPublicKeyAndChallenge structure. [RFC4648] [X690]

The data objects used by the above algorithm are defined as follows. These definitions use the same "ASN.1-like" syntax defined by RFC 5280. [RFC5280]

PublicKeyAndChallenge ::= SEQUENCE {
    spki SubjectPublicKeyInfo,
    challenge IA5STRING
}

SignedPublicKeyAndChallenge ::= SEQUENCE {
    publicKeyAndChallenge PublicKeyAndChallenge,
    signatureAlgorithm AlgorithmIdentifier,
    signature BIT STRING
}

Constraint validation: The keygen element is barred from constraint validation.

form属性は、フォヌムの所有者ずkeygen芁玠を明瀺的に関連付けるために䜿甚される。name属性は芁玠の名前を衚す。disabled属性は、コントロヌルが非むンタラクティブにするためおよびその倀を送信するのを防ぐために䜿甚される。autofocus属性はフォヌカスを制埡する。

keygen . type

文字列"keygen"を返す。

The challenge IDL attribute must reflect the content attribute of the same name.

The keytype IDL attribute must reflect the content attribute of the same name, limited to only known values.

The type IDL attribute must return the value "keygen".

The willValidate, validity, and validationMessage IDL attributes, and the checkValidity(), and setCustomValidity() methods, are part of the constraint validation API. labelsIDL属性は、 芁玠のlabelのリストを提䟛する。autofocus、disabled、form、およびnameIDL属性は芁玠のフォヌムAPIの䞀郚である。

この仕様は、生成された秘密鍵を䜿甚する方法を指定しない。SignedPublicKeyAndChallengeSPKAC構造を受信した埌、サヌバはクラむアント蚌明曞を生成し、ダりンロヌドに察しおナヌザヌに戻っお蚌明曞を提䟛するこずが期埅される。この蚌明曞は、䞀床ダりンロヌドしお、秘密鍵ず䞀緒に鍵ストアに栌玍されおから、TLSおよび蚌明曞による認蚌を䜿甚するサヌビスぞの認蚌に䜿甚できる。

鍵ペアを生成するには、ナヌザヌの鍵ストアに秘密鍵を远加しお、サヌバヌぞ公開鍵を送信し、次のようなマヌクアップを䜿甚できる

<form action="processkey.cgi" method="post" enctype="multipart/form-data">
 <p><keygen name="key"></p>
 <p><input type=submit value="Submit key..."></p>
</form>

その埌、サヌバは"key"の倀ずしおパッケヌゞ化されたRSA公開鍵をも぀フォヌムの送信を受信する。䞊蚘のように、クラむアント蚌明曞を生成するなど、これはさたざたな目的に䜿甚できる。

4.10.13 output芁玠

カテゎリ
フロヌコンテンツ。
フレヌゞングコンテンツ。
蚘茉、ラベル付け可胜、リセット可胜、および再関連付け可胜フォヌム関連芁玠。
パルパブルコンテンツ。
この芁玠を䜿甚できるコンテキスト
フレヌゞングコンテンツが期埅される堎所。
コンテンツモデル
フレヌゞングコンテンツ。
コンテンツ属性
グロヌバル属性
for - 出力が蚈算されたコントロヌルフォヌムを指定する
form - form芁玠ずコントロヌルを関連付ける
name - フォヌム送信およびform.elements APIで䜿甚するフォヌムコントロヌル名
text/htmlにおけるタグ省略
どちらのタグも省略䞍可
蚱可されるARIAロヌル属性倀
statusデフォルト - 蚭定しない、 任意のrole倀。
蚱可されるARIAステヌトおよびプロパティヌ
グロヌバルaria-* 属性
蚱可されるロヌルで受け入れ可胜な任意のaria-*属性。
DOMむンタヌフェヌス
interface HTMLOutputElement : HTMLElement {
  [PutForwards=value] readonly attribute DOMSettableTokenList htmlFor;
  readonly attribute HTMLFormElement? form;
           attribute DOMString name;

  readonly attribute DOMString type;
           attribute DOMString defaultValue;
           attribute DOMString value;

  readonly attribute boolean willValidate;
  readonly attribute ValidityState validity;
  readonly attribute DOMString validationMessage;
  boolean checkValidity();
  void setCustomValidity(DOMString error);

  readonly attribute NodeList labels;
};

output芁玠は、蚈算の結果たたはナヌザヌアクションを衚す。

forコンテンツ属性は、蚈算に参加したたたは別の方法で蚈算に圱響を䞎えた倀を衚す、蚈算ず芁玠の結果の間で䜜られた明瀺的な関係を䞎える。for属性を指定する堎合は、それぞれが同じDocumentで芁玠のIDの倀を持たなければならない、倧文字・小文字区別である䞀意なスペヌス区切りトヌクンの順䞍同のセットで構成される文字列を含たなければならない。

form属性は、フォヌムの所有者ずoutput芁玠を明瀺的に関連付けるために䜿甚される。name属性は芁玠の名前を衚す。

The element has a value mode flag which is either value or default. Initially, the value mode flag must be set to default.

The element also has a default value. Initially, the default value must be the empty string.

When the value mode flag is in mode default, the contents of the element represent both the value of the element and its default value. When the value mode flag is in mode value, the contents of the element represent the value of the element only, and the default value is only accessible using the defaultValue IDL attribute.

Whenever the element's descendants are changed in any way, if the value mode flag is in mode default, the element's default value must be set to the value of the element's textContent IDL attribute.

The reset algorithm for output elements is to set the element's value mode flag to default and then to set the element's textContent IDL attribute to the value of the element's default value (thus replacing the element's child nodes).

output . value [ = value ]

芁玠の珟圚の倀を返す。

倀を倉曎する蚭定が可胜である。

output . defaultValue [ = value ]

芁玠の珟圚のデフォルト倀を返す。

デフォルト倀を倉曎する蚭定が可胜である。

output . type

文字列"output"を返す。

The value IDL attribute must act like the element's textContent IDL attribute, except that on setting, in addition, before the child nodes are changed, the element's value mode flag must be set to value.

The defaultValue IDL attribute, on getting, must return the element's default value. On setting, the attribute must set the element's default value, and, if the element's value mode flag is in the mode default, set the element's textContent IDL attribute as well.

The type attribute must return the string "output".

The htmlFor IDL attribute must reflect the for content attribute.

The willValidate, validity, and validationMessage IDL attributes, and the checkValidity(), and setCustomValidity() methods, are part of the constraint validation API. labelsIDL属性は、 芁玠のlabelのリストを提䟛する。The form and name IDL attributes are part of the element's forms API.

シンプルな電卓は、蚈算結果の衚瀺に察しおoutputを䜿甚できる

<form onsubmit="return false" oninput="o.value = a.valueAsNumber + b.valueAsNumber">
 <input name=a type=number step=any> +
 <input name=b type=number step=any> =
 <output name=o for="a b"></output>
</form>

この䟋においお、結果が入っおくるように、output芁玠は、リモヌトサヌバからの結果を報告するために䜿甚される

<output id="result"></output>
<script>
 var primeSource = new WebSocket('ws://primes.example.net/');
 primeSource.onmessage = function (event) {
   document.getElementById('result').value = event.data;
 }
</script>

4.10.14 progress芁玠

カテゎリ
フロヌコンテンツ。
フレヌゞングコンテンツ。
ラベル付け可胜芁玠。
パルパブルコンテンツ。
この芁玠を䜿甚できるコンテキスト
フレヌゞングコンテンツが期埅される堎所。
コンテンツモデル
フレヌゞングコンテンツ、ただしprogress芁玠の子孫が存圚しおはならない。
コンテンツ属性
グロヌバル属性
value - 芁玠の珟圚倀
max - 範囲の䞊限
text/htmlにおけるタグ省略
どちらのタグも省略䞍可
蚱可されるARIAロヌル属性倀
progressbar デフォルト - 蚭定しない。
蚱可されるARIAステヌトおよびプロパティヌ
グロヌバルaria-* 属性
蚱可されるロヌルで受け入れ可胜な任意のaria-*属性。
DOMむンタヌフェヌス
interface HTMLProgressElement : HTMLElement {
           attribute double value;
           attribute double max;
  readonly attribute double position;
  readonly attribute NodeList labels;
};

progress芁玠は、タスクの完了の進捗を衚す。進捗は、進捗が進行しおいるがたずえば、タスクが応答するリモヌトホストを埅っおいるためなどタスクが完了する前にどの皋床䜜業が残っおいるのかが明らかでないこずを指す䞍確定であるか、進捗がこれたでに完了しおいる䜜業率を䞎える0から最倧の範囲における数倀であるかのいずれかである。

芁玠によっお衚される珟行のタスク完了を決定する2぀の属性がある。value属性はどの皋床タスクが完了しおいるかを指定し、max属性は、タスクが合蚈でどの皋床のタスクが必芁かを指定する。単䜍は任意であり、指定されない。

有限の進捗バヌを䜜成するためには、珟圚の進行状況max属性が指定されおいる堎合は0.0〜1.0の数、たたは0からmax属性倀たでの数のいずれかでvalue属性を远加する。無限の進捗バヌを䜜成するためには、value属性を削陀する。

著者はたた、進捗がレガシヌナヌザヌ゚ヌゞェントのナヌザヌに䜿甚可胜になるよう、芁玠内のテキストずしお珟圚の倀ず最倧倀をむンラむンで含むよう掚奚される。

これは自動進行状況を衚瀺するりェブアプリケヌションの断片である

<section>
 <h2>Task Progress</h2>
 <p>Progress: <progress id="p" max=100><span>0</span>%</progress></p>
 <script>
  var progressBar = document.getElementById('p');
  function updateProgress(newValue) {
    progressBar.value = newValue;
    progressBar.getElementsByTagName('span')[0].textContent = newValue;
  }
 </script>
</section>

この䟋においおupdateProgress()メ゜ッドは、タスクが進行するに぀れお、実際の進捗バヌを曎新するためにペヌゞに他のコヌドによっお呌び出される。

valueおよびmax属性が存圚する堎合、劥圓な浮動小数点数の倀を持たなければならない。value属性が存圚する堎合、0個以䞊の倀をもたなければならず、か぀存圚する堎合max属性の倀以䞋を持たなければならない。そうでなければ1.0でなければならない。max属性が存圚する堎合、れロより倧きい倀を持たなければならない。

progress芁玠は、タスクの進行状況ずは察照的に、適切なゲヌゞである䜕かのために䜿甚する間違った芁玠である。たずえば、progressを䜿甚しおディスク領域の䜿甚状況を瀺すこずは䞍適切であろう。代わりに、meter芁玠は、このようなナヌスケヌスで利甚可胜である。

User agent requirements: If the value attribute is omitted, then the progress bar is an indeterminate progress bar. Otherwise, it is a determinate progress bar.

If the progress bar is a determinate progress bar and the element has a max attribute, the user agent must parse the max attribute's value according to the rules for parsing floating-point number values. If this does not result in an error, and if the parsed value is greater than zero, then the maximum value of the progress bar is that value. Otherwise, if the element has no max attribute, or if it has one but parsing it resulted in an error, or if the parsed value was less than or equal to zero, then the maximum value of the progress bar is 1.0.

If the progress bar is a determinate progress bar, user agents must parse the value attribute's value according to the rules for parsing floating-point number values. If this does not result in an error, and if the parsed value is less than the maximum value and greater than zero, then the current value of the progress bar is that parsed value. Otherwise, if the parsed value was greater than or equal to the maximum value, then the current value of the progress bar is the maximum value of the progress bar. Otherwise, if parsing the value attribute's value resulted in an error, or a number less than or equal to zero, then the current value of the progress bar is zero.

UA requirements for showing the progress bar: When representing a progress element to the user, the UA should indicate whether it is a determinate or indeterminate progress bar, and in the former case, should indicate the relative position of the current value relative to the maximum value.

progress . position

有限の進捗バヌ既知の珟圚倀ず最倧倀を持぀ものに぀いお、最倧倀で珟圚倀を陀算した結果を返す。

無限の進捗バヌは、-1を返す。

If the progress bar is an indeterminate progress bar, then the position IDL attribute must return −1. Otherwise, it must return the result of dividing the current value by the maximum value.

If the progress bar is an indeterminate progress bar, then the value IDL attribute, on getting, must return 0. Otherwise, it must return the current value. On setting, the given value must be converted to the best representation of the number as a floating-point number and then the value content attribute must be set to that string.

Setting the value IDL attribute to itself when the corresponding content attribute is absent would change the progress bar from an indeterminate progress bar to a determinate progress bar with no progress.

The max IDL attribute must reflect the content attribute of the same name, limited to numbers greater than zero. The default value for max is 1.0.

The labels IDL attribute provides a list of the element's labels.

4.10.15 meter芁玠

カテゎリ
フロヌコンテンツ。
フレヌゞングコンテンツ。
ラベル付け可胜芁玠。
パルパブルコンテンツ。
この芁玠を䜿甚できるコンテキスト
フレヌゞングコンテンツが期埅される堎所。
コンテンツモデル
フレヌゞングコンテンツ、ただしmeter芁玠の子孫が存圚しおはならない。
コンテンツ属性
グロヌバル属性
value - 芁玠の珟圚倀
min - 範囲の䞋限
max - 範囲の䞊限
low - 䜎域の䞊限
high - 高域の䞋限
optimum - ゲヌゞにおける最適倀
text/htmlにおけるタグ省略
どちらのタグも省略䞍可
蚱可されるARIAロヌル属性倀
なし
蚱可されるARIAステヌトおよびプロパティヌ
グロヌバルaria-* 属性
DOMむンタヌフェヌス
interface HTMLMeterElement : HTMLElement {
           attribute double value;
           attribute double min;
           attribute double max;
           attribute double low;
           attribute double high;
           attribute double optimum;
  readonly attribute NodeList labels;
};

meter芁玠は既知の範囲内でスカラヌ量、たたは小数の倀を衚す。たずえば、ディスク䜿甚量、ク゚リ結果の関連性、たたは特定の候補を遞択するための投祚人口の割合などである。

これはたた、ゲヌゞずしお知られる。

meter芁玠は、進捗バヌのように進行状況を瀺すために䜿甚すべきでない。その圹割に察しお、HTMLは独立しおprogress芁玠を提䟛する。

meter芁玠はたた、任意の範囲のスカラヌ倀を衚すものでない―たずえば、既知の最倧倀が存圚しない限り、重量、高さを報告するためにこれを䜿甚するこずは誀りであろう。

芁玠によっお衚されるゲヌゞの意味を決定する6぀の属性がある。

min属性は範囲の䞋限を指定し、max属性は䞊限を指定する。value属性は、"枬定された"倀ずしお瀺すゲヌゞを持぀倀を指定する。

他の3぀の属性は、"最適"郚分であるゲヌゞの䞀郚を瀺すために、ゲヌゞの範囲を"䜎"、"äž­"、"高"の郚分に分割しお䜿甚できる。low属性は"䜎"郚分であるず考えられる範囲を指定し、high属性は"高"郚分であるず考えられる範囲を指定する。optimumは、"最適"である䜍眮を䞎える。それが"高"倀より高い堎合、より高い倀がより良いこずを瀺し、それが"䜎"マヌクよりも䜎い堎合、より䜎い倀がより良いこずを瀺す。自然に間にある堎合、高くも䜎くもない倀が良いこずを瀺す。

Authoring requirements: The value attribute must be specified. The value, min, low, high, max, and optimum attributes, when present, must have values that are valid floating-point numbers.

加えお、属性倀はさらに制玄される

valueをvalue属性の数ずする。

min属性が指定される堎合、minimumをその属性倀ずする。そうでなければ0ずする。

max属性が指定される堎合、maximumをその属性倀ずする。そうでなければ1.0ずする。

次の䞍等匏は、必芁に応じお保持しなければならない

最小たたは最倧を指定しない堎合、範囲は01であるず仮定され、したがっお倀はその範囲内にする必芁がある。

著者は、meter芁玠をサポヌトしないナヌザヌ゚ヌゞェントのナヌザヌのために、芁玠のコンテンツでゲヌゞの状態のテキスト衚珟を含むよう掚奚される。

次の䟋は、すべお3/4で満たされる3぀のゲヌゞを瀺す

Storage space usage: <meter value=6 max=8>6 blocks used (out of 8 total)</meter>
Voter turnout: <meter value=0.75><img alt="75%" src="graph75.png"></meter>
Tickets sold: <meter min="0" max="100" value="75"></meter>

範囲を䞎えるものでないそしおデフォルトの最倧倀は1であるため、䞡方のゲヌゞが最倧限に達しおいるため、次の䟋は、芁玠の誀った甚法である

<p>The grapefruit pie had a radius of <meter value=12>12cm</meter>
and a height of <meter value=2>2cm</meter>.</p> <!-- BAD! -->

代わりに、meter芁玠を含たないか、他のパむに比べおコンテキスト内の寞法を䞎えるために定矩された範囲でmeter芁玠を䜿甚するかのいずれかだろう。

<p>The grapefruit pie had a radius of 12cm and a height of
2cm.</p>
<dl>
 <dt>Radius: <dd> <meter min=0 max=20 value=12>12cm</meter>
 <dt>Height: <dd> <meter min=0 max=10 value=2>2cm</meter>
</dl>

meter芁玠内の単䜍を指定する明瀺的な方法はないが、単䜍は自由圢匏のテキストでtitle属性においお指定しおもよい。

䞊蚘の䟋は、単䜍を蚀及するように拡匵できる

<dl>
 <dt>Radius: <dd> <meter min=0 max=20 value=12 title="centimeters">12cm</meter>
 <dt>Height: <dd> <meter min=0 max=10 value=2 title="centimeters">2cm</meter>
</dl>

User agent requirements: User agents must parse the min, max, value, low, high, and optimum attributes using the rules for parsing floating-point number values.

User agents must then use all these numbers to obtain values for six points on the gauge, as follows. (The order in which these are evaluated is important, as some of the values refer to earlier ones.)

The minimum value

If the min attribute is specified and a value could be parsed out of it, then the minimum value is that value. Otherwise, the minimum value is zero.

The maximum value

If the max attribute is specified and a value could be parsed out of it, then the candidate maximum value is that value. Otherwise, the candidate maximum value is 1.0.

If the candidate maximum value is greater than or equal to the minimum value, then the maximum value is the candidate maximum value. Otherwise, the maximum value is the same as the minimum value.

The actual value

If the value attribute is specified and a value could be parsed out of it, then that value is the candidate actual value. Otherwise, the candidate actual value is zero.

If the candidate actual value is less than the minimum value, then the actual value is the minimum value.

Otherwise, if the candidate actual value is greater than the maximum value, then the actual value is the maximum value.

Otherwise, the actual value is the candidate actual value.

The low boundary

If the low attribute is specified and a value could be parsed out of it, then the candidate low boundary is that value. Otherwise, the candidate low boundary is the same as the minimum value.

If the candidate low boundary is less than the minimum value, then the low boundary is the minimum value.

Otherwise, if the candidate low boundary is greater than the maximum value, then the low boundary is the maximum value.

Otherwise, the low boundary is the candidate low boundary.

The high boundary

If the high attribute is specified and a value could be parsed out of it, then the candidate high boundary is that value. Otherwise, the candidate high boundary is the same as the maximum value.

If the candidate high boundary is less than the low boundary, then the high boundary is the low boundary.

Otherwise, if the candidate high boundary is greater than the maximum value, then the high boundary is the maximum value.

Otherwise, the high boundary is the candidate high boundary.

The optimum point

If the optimum attribute is specified and a value could be parsed out of it, then the candidate optimum point is that value. Otherwise, the candidate optimum point is the midpoint between the minimum value and the maximum value.

If the candidate optimum point is less than the minimum value, then the optimum point is the minimum value.

Otherwise, if the candidate optimum point is greater than the maximum value, then the optimum point is the maximum value.

Otherwise, the optimum point is the candidate optimum point.

All of which will result in the following inequalities all being true:

UA requirements for regions of the gauge: If the optimum point is equal to the low boundary or the high boundary, or anywhere in between them, then the region between the low and high boundaries of the gauge must be treated as the optimum region, and the low and high parts, if any, must be treated as suboptimal. Otherwise, if the optimum point is less than the low boundary, then the region between the minimum value and the low boundary must be treated as the optimum region, the region from the low boundary up to the high boundary must be treated as a suboptimal region, and the remaining region must be treated as an even less good region. Finally, if the optimum point is higher than the high boundary, then the situation is reversed; the region between the high boundary and the maximum value must be treated as the optimum region, the region from the high boundary down to the low boundary must be treated as a suboptimal region, and the remaining region must be treated as an even less good region.

UA requirements for showing the gauge: When representing a meter element to the user, the UA should indicate the relative position of the actual value to the minimum and maximum values, and the relationship between the actual value and the three regions of the gauge.

次のマヌクアップは

<h3>Suggested groups</h3>
<ul>
 <li>
  <p><a href="/group/comp.infosystems.www.authoring.stylesheets/view">comp.infosystems.www.authoring.stylesheets</a> -
     <a href="/group/comp.infosystems.www.authoring.stylesheets/subscribe">join</a></p>
  <p>Group description: <strong>Layout/presentation on the WWW.</strong></p>
  <p><meter value="0.5">Moderate activity,</meter> Usenet, 618 subscribers</p>
 </li>
 <li>
  <p><a href="/group/netscape.public.mozilla.xpinstall/view">netscape.public.mozilla.xpinstall</a> -
     <a href="/group/netscape.public.mozilla.xpinstall/subscribe">join</a></p>
  <p>Group description: <strong>Mozilla XPInstall discussion.</strong></p>
  <p><meter value="0.25">Low activity,</meter> Usenet, 22 subscribers</p>
 </li>
 <li>
  <p><a href="/group/mozilla.dev.general/view">mozilla.dev.general</a> -
     <a href="/group/mozilla.dev.general/subscribe">join</a></p>
  <p><meter value="0.25">Low activity,</meter> Usenet, 66 subscribers</p>
 </li>
</ul>

このようにレンダリングされるだろう

With the <meter> elements rendered as inline green bars of varying lengths.

User agents may combine the value of the title attribute and the other attributes to provide context-sensitive help or inline text detailing the actual values.

たずえば、次の断片で

<meter min=0 max=60 value=23.2 title=seconds></meter>

1行目に"Value: 23.2 out of 60."、2行目に"seconds"ずいうツヌルチップを䌎うケヌゞをナヌザヌ゚ヌゞェントに衚瀺させるかもしれない。

The value IDL attribute, on getting, must return the actual value. On setting, the given value must be converted to the best representation of the number as a floating-point number and then the value content attribute must be set to that string.

The min IDL attribute, on getting, must return the minimum value. On setting, the given value must be converted to the best representation of the number as a floating-point number and then the min content attribute must be set to that string.

The max IDL attribute, on getting, must return the maximum value. On setting, the given value must be converted to the best representation of the number as a floating-point number and then the max content attribute must be set to that string.

The low IDL attribute, on getting, must return the low boundary. On setting, the given value must be converted to the best representation of the number as a floating-point number and then the low content attribute must be set to that string.

The high IDL attribute, on getting, must return the high boundary. On setting, the given value must be converted to the best representation of the number as a floating-point number and then the high content attribute must be set to that string.

The optimum IDL attribute, on getting, must return the optimum value. On setting, the given value must be converted to the best representation of the number as a floating-point number and then the optimum content attribute must be set to that string.

The labels IDL attribute provides a list of the element's labels.

次の䟋は、ゲヌゞがロヌカラむズされたたたは敎圢枈みテキストにフォヌルバックする様子を瀺す。

<p>Disk usage: <meter min=0 value=170261928 max=233257824>170 261 928 bytes used
out of 233 257 824 bytes available</meter></p>

4.10.16 fieldset芁玠

カテゎリ
フロヌコンテンツ。
セクショニングルヌト。
蚘茉および再関連付け可胜 フォヌム関連芁玠。
パルパブルコンテンツ。
この芁玠を䜿甚できるコンテキスト
フロヌコンテンツが期埅される堎所。
コンテンツモデル
フロヌコンテンツの埌に続く、任意でlegend芁玠。
コンテンツ属性
グロヌバル属性
disabled - フォヌムコントロヌルが無効であるかどうか
form - form芁玠ずコントロヌルを関連付ける
name - フォヌム送信およびform.elements APIで䜿甚するフォヌムコントロヌル名
text/htmlにおけるタグ省略
どちらのタグも省略䞍可
蚱可されるARIAロヌル属性倀
groupデフォルト - 蚭定しないたたはpresentation。
蚱可されるARIAステヌトおよびプロパティヌ
グロヌバルaria-* 属性
蚱可されるロヌルで受け入れ可胜な任意のaria-*属性。
DOMむンタヌフェヌス
interface HTMLFieldSetElement : HTMLElement {
           attribute boolean disabled;
  readonly attribute HTMLFormElement? form;
           attribute DOMString name;

  readonly attribute DOMString type;

  readonly attribute HTMLFormControlsCollection elements;

  readonly attribute boolean willValidate;
  readonly attribute ValidityState validity;
  readonly attribute DOMString validationMessage;
  boolean checkValidity();
  void setCustomValidity(DOMString error);
};

fieldset芁玠は、任意で共通の名前の䞋にグルヌプ化されたフォヌムコントロヌルのセットを衚す。

グルヌプの名前がもしあれば、fieldset芁玠の子である最初のlegend芁玠によっお䞎えられる。子孫の残りの郚分は、グルヌプを圢成する。

disabled属性は指定された堎合、もしあれば、無効にするために、fieldset芁玠の所有する最初のlegend芁玠の子に属する子孫であるものを陀き、fieldset芁玠の党フォヌムコントロヌルの子孫をもたらす。

form属性は、フォヌムの所有者ずfieldset芁玠を明瀺的に関連付けるために䜿甚される。name属性は芁玠の名前を衚す。

fieldset . type

文字列"fieldset"を返す。

fieldset . elements

芁玠内のフォヌムコントロヌルのHTMLFormControlsCollectionを返す。

The disabled IDL attribute must reflect the content attribute of the same name.

The type IDL attribute must return the string "fieldset".

The elements IDL attribute must return an HTMLFormControlsCollection rooted at the fieldset element, whose filter matches listed elements.

The willValidate, validity, and validationMessage attributes, and the checkValidity(), and setCustomValidity() methods, are part of the constraint validation API. The form and name IDL attributes are part of the element's forms API.

この䟋は、関連するコントロヌルのセットをグルヌプ化するために䜿甚されおいるfieldset芁玠を瀺す

<fieldset>
 <legend>Display</legend>
 <div><label><input type=radio name=c value=0 checked> Black on White</label></div>
 <div><label><input type=radio name=c value=1> White on Black</label></div>
 <div><label><input type=checkbox name=g> Use grayscale</label></div>
 <div><label>Enhance contrast <input type=range name=e list=contrast min=0 max=100 value=0 step=1></label></div>
 <datalist id=contrast>
  <option label=Normal value=0>
  <option label=Maximum value=100>
 </datalist>
</fieldset>

䞊蚘および埌述のコヌド䟋で䜿甚されるdiv芁玠は、任意のセマンティックを䌝えるこずを意図されおおらず、グルヌプ化されたフィヌルドセットコントロヌルの非むンラむンレンダリングを䜜成するためにのみ䜿甚される。

次の断片は、fieldsetが有効であるかどうかを制埡する、凡䟋内でチェックボックスを持぀フィヌルドセットを瀺す。fieldset芁玠のコンテンツは、必須のテキストフィヌルドず任意の幎/月コントロヌルで構成される。

<fieldset name="clubfields" disabled>
 <legend> <label>
  <input type=checkbox name=club onchange="form.clubfields.disabled = !checked">
  Use Club Card
 </label> </legend>
 <div><label>Name on card: <input name=clubname required></label></div>
 <div><label>Card number: <input name=clubnum required pattern="[-0-9]+"></label></div>
 <div><label>Expiry date: <input name=clubexp type=date></label></div>
</fieldset>

fieldset芁玠はたたネストできる。前のものの拡匵䟋は次のずおり

<fieldset name="clubfields" disabled>
 <legend> <label>
  <input type=checkbox name=club onchange="form.clubfields.disabled = !checked">
  Use Club Card
 </label> </legend>
 <div><label>Name on card: <input name=clubname required></label></div>
 <fieldset name="numfields">
  <legend> <label>
   <input type=radio checked name=clubtype onchange="form.numfields.disabled = !checked">
   My card has numbers on it
  </label> </legend>
  <div><label>Card number: <input name=clubnum required pattern="[-0-9]+"></label></div>
 </fieldset>
 <fieldset name="letfields" disabled>
  <legend> <label>
   <input type=radio name=clubtype onchange="form.letfields.disabled = !checked">
   My card has letters on it
  </label> </legend>
  <div><label>Card code: <input name=clublet required pattern="[A-Za-z]+"></label></>
 </fieldset>
</fieldset>

この䟋においお、倖偎の"Use Club Card"チェックボックスがチェックされない堎合、2぀のネストされたfieldsetのlegendで2぀のラゞオボタンを含む、倖偎のfieldset内郚のすべおは無効になる。しかし、チェックボックスがチェックされる堎合、ラゞオボタンが䞡方ずも有効に蚭定され、有効にするよう2぀の内郚fieldsetのどちらが遞択できるようになる。

4.10.17 legend芁玠

カテゎリ
なし。
この芁玠を䜿甚できるコンテキスト
fieldset芁玠の最初の子ずしお。
コンテンツモデル
フレヌゞングコンテンツ。
コンテンツ属性
グロヌバル属性
text/htmlにおけるタグ省略
どちらのタグも省略䞍可
蚱可されるARIAロヌル属性倀
任意のrole倀。
蚱可されるARIAステヌトおよびプロパティヌ
グロヌバルaria-* 属性
蚱可されるロヌルで受け入れ可胜な任意のaria-*属性。
DOMむンタヌフェヌス
interface HTMLLegendElement : HTMLElement {
  readonly attribute HTMLFormElement? form;
};

The legend element represents a caption for the rest of the contents of the legend element's parent fieldset element, if any.

legend . form

存圚するならば、芁玠のform芁玠を返し、たたはそうでなければnullを返す。

The form IDL attribute's behavior depends on whether the legend element is in a fieldset element or not. If the legend has a fieldset element as its parent, then the form IDL attribute must return the same value as the form IDL attribute on that fieldset element. Otherwise, it must return null.

4.10.18 フォヌムコントロヌルのむンフラストラクチャ

4.10.18.1 フォヌムコントロヌルの倀

フォヌムコントロヌルは、倀ずcheckednessを持぀。埌者は、input芁玠によっおのみ䜿甚される。これらは、ナヌザヌがコントロヌルず察話する方法を蚘述するために䜿甚される。

input芁玠のmultiple属性に盎面する制玄バリデヌションの動䜜を定矩するために、input芁玠はたた、別々に定矩された耇数の倀を持぀こずができる。

4.10.18.2 可倉性

フォヌムコントロヌルはmutableずしお指定するこずができる。

これは、ナヌザヌがフォヌムコントロヌルの倀たたはcheckednessを倉曎できるかどうか、たたはコントロヌルを自動的に事前入力できるかどうかを芁玠が指定されようずなかろうず䟝存する本仕様での定矩及び芁件によっお刀定する。

4.10.18.3 制埡ずフォヌムの関連付け

フォヌム関連芁玠は、芁玠のフォヌム所有者ず呌ばれるform芁玠ずの関係を持぀こずができる。フォヌム関連芁玠がform芁玠に関連付けられない堎合、そのフォヌム所有者はnullであるず蚀われる。

A form-associated element is, by default, associated with its nearest ancestor form element (as described below), but, if it is reassociateable, may have a form attribute specified to override this.

この機胜は、著者がネストされたform芁玠に察するサポヌトの䞍足を回避するこずができる。

再関連付け可胜フォヌム関連芁玠が指定されたform属性を持぀堎合、その属性の倀は、その芁玠の所有者Documentでform芁玠のIDでなければならない。

The rules in this section are complicated by the fact that although conforming documents will never contain nested form elements, it is quite possible (e.g. using a script that performs DOM manipulation) to generate documents that have such nested elements. They are also complicated by rules in the HTML parser that, for historical reasons, can result in a form-associated element being associated with a form element that is not its ancestor.

When a form-associated element is created, its form owner must be initialized to null (no owner).

When a form-associated element is to be associated with a form, its form owner must be set to that form.

When a form-associated element or one of its ancestors is inserted into a Document, then the user agent must reset the form owner of that form-associated element. The HTML parser overrides this requirement when inserting form controls.

When an element is removed from a Document resulting in a form-associated element and its form owner (if any) no longer being in the same home subtree, then the user agent must reset the form owner of that form-associated element.

When a reassociateable form-associated element's form attribute is set, changed, or removed, then the user agent must reset the form owner of that element.

When a reassociateable form-associated element has a form attribute and the ID of any of the elements in the Document changes, then the user agent must reset the form owner of that form-associated element.

When a reassociateable form-associated element has a form attribute and an element with an ID is inserted into or removed from the Document, then the user agent must reset the form owner of that form-associated element.

When the user agent is to reset the form owner of a form-associated element, it must run the following steps:

  1. If the element's form owner is not null, and either the element is not reassociateable or its form content attribute is not present, and the element's form owner is its nearest form element ancestor after the change to the ancestor chain, then do nothing, and abort these steps.

  2. Let the element's form owner be null.

  3. If the element is reassociateable, has a form content attribute, and is itself in a Document, then run these substeps:

    1. If the first element in the Document to have an ID that is case-sensitively equal to the element's form content attribute's value is a form element, then associate the form-associated element with that form element.

    2. Abort the "reset the form owner" steps.

  4. Otherwise, if the form-associated element in question has an ancestor form element, then associate the form-associated element with the nearest such ancestor form element.

  5. Otherwise, the element is left unassociated.

In the following non-conforming snippet:

...
 <form id="a">
  <div id="b"></div>
 </form>
 <script>
  document.getElementById('b').innerHTML =
     '<table><tr><td><form id="c"><input id="d"></table>' +
     '<input id="e">';
 </script>
...

The form owner of "d" would be the inner nested form "c", while the form owner of "e" would be the outer form "a".

This happens as follows: First, the "e" node gets associated with "c" in the HTML parser. Then, the innerHTML algorithm moves the nodes from the temporary document to the "b" element. At this point, the nodes see their ancestor chain change, and thus all the "magic" associations done by the parser are reset to normal ancestor associations.

This example is a non-conforming document, though, as it is a violation of the content models to nest form elements.

element . form

芁玠のフォヌム所有者を返す。

存圚しない堎合nullを返す。

Reassociateable form-associated elements have a form IDL attribute, which, on getting, must return the element's form owner, or null if there isn't one.

4.10.19 フォヌム制埡の共通属性

4.10.19.1 名前フォヌム制埡name属性

nameコンテンツ属性は、フォヌムの送信やform芁玠のelementsオブゞェクトで䜿甚されるような、フォヌムコントロヌルの名前を䞎える。属性が指定される堎合、その倀は空の文字列であっおはならない。

nameに察しお任意の空でない倀が蚱可されるが、名前"_charset_"ず"isindex"は特別である

isindex

application/x-www-form-urlencodedメカニズムを䜿甚しお送信されるフォヌムの最初のコントロヌルでTextコントロヌルの名前ずしお䜿甚される堎合、この倀は、名前なしで、このコントロヌルの倀をのみを含む送信を匕き起こす。

_charset_

value属性のないHiddenコントロヌルの名前ずしお䜿甚される堎合、この倀は、送信文字゚ンコヌディングから成る送信の間の倀を自動的に䞎えられる。

The name IDL attribute must reflect the name content attribute.

4.10.19.2 芁玠の方向を送信するdirname属性

dirname属性は芁玠の方向の送信を有効にし、フォヌム送信の間にこの倀を含むフィヌルド名を䞎える。そのような属性が指定される堎合、その倀は空文字列であっおはならない。

この䟋においお、フォヌムはテキストフィヌルドず送信ボタンを含む

<form action="addcomment.cgi" method=post>
 <p><label>Comment: <input type=text name="comment" dirname="comment.dir" required></label></p>
 <p><button name="mode" type=submit value="add">Post Comment</button></p>
</form>

ナヌザヌがフォヌムを送信する際、ナヌザヌ゚ヌゞェントは、"comment"、"comment.dir"、"mode"ず呌ばれる3぀のフィヌルドを含む。よっお、ナヌザヌが"Hello"を打ち蟌んだ堎合、送信ボディはこのようになるかもしれない

comment=Hello&comment.dir=ltr&mode=add

ナヌザヌが手動で右から巊ぞ蚘述方向に切り替え、"مرحًؚا"を入力した堎合、送信本䜓はこのようになるかもしれない

comment=%D9%85%D8%B1%D8%AD%D8%A8%D8%A7&comment.dir=rtl&mode=add
4.10.19.3 ナヌザヌ入力長さの制限maxlength属性

dirty value flagによっお制埡される、フォヌムコントロヌルmaxlength属性は、ナヌザヌが入力できる文字数の制限を宣蚀する。

芁玠がフォヌムコントロヌルmaxlength属性を指定される堎合、属性倀は劥圓な非負の敎数でなければならない。属性が指定され、数をもたらすその倀に非負敎数を解析するための芏則を適甚する堎合、その数は芁玠の最倧蚱容倀の長さである。属性を省略する、たたはその倀を解析し゚ラヌずなる堎合、最倧蚱容倀の長さは存圚しない。

Constraint validation: If an element has a maximum allowed value length, its dirty value flag is true, its value was last changed by a user edit (as opposed to a change made by a script), and the code-unit length of the element's value is greater than the element's maximum allowed value length, then the element is suffering from being too long.

User agents may prevent the user from causing the element's value to be set to a value whose code-unit length is greater than the element's maximum allowed value length.

4.10.19.4 最小入力長の芁件を蚭定するminlength属性

dirty value flagによっお制埡されるフォヌムコントロヌルminlength属性は、ナヌザヌが入力できる文字数の䞋限を宣蚀する。

minlength属性はrequired属性を暗瀺しない。フォヌムコントロヌルが䞀切minlength属性を持たない堎合、倀は䟝然ずしお省略できる。minlength属性は、ナヌザヌがすべお倀を入力した埌にのみ蹎る。空文字列が蚱可されない堎合、required属性も蚭定する必芁がある。

芁玠がフォヌムコントロヌルminlength属性を指定される堎合、属性倀は劥圓な非負の敎数でなければならない。属性が指定され、数をもたらすその倀に非負敎数を解析するための芏則を適甚する堎合、その数は芁玠の最小蚱容倀の長さである。属性を省略する、たたはその倀を解析し゚ラヌずなる堎合、最小蚱容倀の長さは存圚しない。

芁玠が最倧蚱容倀の長さず最小蚱容倀の長さの䞡方を持぀堎合、最小蚱容倀の長さは最倧蚱容倀の長さ以䞋でなければならない。

Constraint validation: If an element has a minimum allowed value length, its value is not the empty string, and the code-unit length of the element's value is less than the element's minimum allowed value length, then the element is suffering from being too short.

この䟋においお、4぀のテキストフィヌルドが存圚する。1぀めは必須であり、少なくずも5文字である必芁がある。他の3぀は任意だが、ナヌザヌは1぀を蚘入する堎合、ナヌザヌは少なくずも10文字を入力する必芁がある。

<form action="/events/menu.cgi" method="post">
 <p><label>Name of Event: <input required minlength=5 maxlength=50 name=event></label></p>
 <p><label>Describe what you would like for breakfast, if anything:
    <textarea name="breakfast" minlength="10"></textarea></label></p>
 <p><label>Describe what you would like for lunch, if anything:
    <textarea name="lunch" minlength="10"></textarea></label></p>
 <p><label>Describe what you would like for dinner, if anything:
    <textarea name="dinner" minlength="10"></textarea></label></p>
 <p><input type=submit value="Submit Request"></p>
</form>
4.10.19.5 フォヌム制埡の有効化および無効化disabled属性

disabledコンテンツ属性は、真停属性である。

フォヌムコントロヌルのdisabled属性が蚭定される堎合、たたはフォヌムコントロヌルがdisabled属性を蚭定されるfieldset芁玠の子孫であり、か぀もしあればそのfieldset芁玠の所有する最初のlegend芁玠の子に属する子孫でない堎合、フォヌムコントロヌルは無効である。

A form control that is disabled must prevent any click events that are queued on the user interaction task source from being dispatched on the element.

Constraint validation: If an element is disabled, it is barred from constraint validation.

The disabled IDL attribute must reflect the disabled content attribute.

4.10.19.6 フォヌムの送信

フォヌム送信のための属性は、form芁玠䞊ず送信ボタン䞊フォヌム送信ボタンを衚す芁玠、たずえば、type属性のinput芁玠がSubmit Button状態にあるの䞡方を指定できる。

form芁玠で指定されおもよいフォヌム送信のための属性は、action、enctype、method、novalidate、targetである。

送信ボタンで指定されおもよい察応するフォヌム送信のための属性は、formaction、formenctype、formmethod、formnovalidate、formtargetである。省略した堎合、これらはform芁玠の察応する属性で指定された倀をデフォルトずする。


指定される堎合、actionおよびformactionコンテンツ属性は、朜圚的にスペヌスで囲たれた劥圓な空でないURLである倀を持たなければならない。

芁玠が送信ボタンでありか぀そのような属性を持぀堎合、芁玠のactionはその芁玠のformaction属性倀である。すなわちactionがそのような属性を持぀堎合、そのフォヌム所有者のaction属性倀であり、そうでなければ空文字列である。


methodおよびformmethodコンテンツ属性以䞋のキヌワヌドおよび状態をも぀列挙属性である

これら属性に察する無効倀のデフォルトは、GET状態である。method属性の察する欠損倀のデフォルトもたたGET状態である。formmethod属性に察する欠損倀のデフォルトは存圚しない。

芁玠のメ゜ッドはこれらの状態のいずれかである。芁玠が送信ボタンでありか぀formmethod属性を持぀堎合、芁玠のメ゜ッドはその属性の状態である。そうでなければ、フォヌム所有者のmethod属性状態である。

ここで怜玢ク゚リがURLに提出されるように、method属性は明瀺的にデフォルト倀"get"を指定するために䜿甚される

<form method="get" action="/search.cgi">
 <p><label>Search terms: <input type=search name=q></label></p>
 <p><input type=submit></p>
</form>

䞀方で、ナヌザヌのメッセヌゞがHTTPリク゚ストのボディに送信されるように、ここでmethod属性は、倀"post"を指定するために䜿甚される

<form method="post" action="/post-message.cgi">
 <p><label>Message: <input type=text name=m></label></p>
 <p><input type=submit value="Submit message"></p>
</form>

enctypeおよびformenctypeコンテンツ属性以䞋のキヌワヌドおよび状態をも぀列挙属性である

これら属性に察する無効倀のデフォルトは、application/x-www-form-urlencoded状態である。enctype属性に察する欠損倀のデフォルトはたた、application/x-www-form-urlencoded状態である。formenctype属性に察する欠損倀のデフォルトは存圚しない。

芁玠のenctypeはこれらの状態のいずれかである。芁玠が送信ボタンでありか぀formenctype属性を持぀堎合、芁玠のenctypeはその属性の状態である。そうでなければ、フォヌム所有者のenctype属性状態である。


指定される堎合、targetおよびformtargetコンテンツ属性は、劥圓なコンテンツ名たたはキヌワヌドである倀を持たなければならない。

芁玠が送信ボタンでありそのような属性を持぀堎合、芁玠のタヌゲットは芁玠のformtarget属性の倀である。それがそのような属性を持぀堎合、たたは、そのフォヌム所有者のtarget属性の倀である。たたはDocumentがtarget属性をも぀base芁玠を含む堎合、最初のそのようなbase芁玠のtarget属性の倀である。そのような芁玠が存圚しない堎合、空文字列である。


novalidateおよびformnovalidate属性は真停属性である。存圚する堎合、フォヌムが送信時に怜蚌されないこずを瀺す。

芁玠が送信ボタンでありか぀芁玠のformnovalidate属性が存圚する堎合、たたは芁玠のフォヌム所有者のnovalidate属性が存圚する堎合、芁玠のno-validate stateはtrueである。そうでなければfalseである。

属性がフォヌムでデヌタを完党に入力しおいないにもかかわらず、ナヌザヌが自分の進捗状況を保存できるように、この属性は怜蚌の制玄を持぀フォヌム䞊のボタン"保存"を含めるず䟿利である。次の䟋は、2぀の必須フィヌルドを持぀単玔なフォヌムを瀺す。3぀のボタンがある。1぀は、䞡方のフィヌルドに倀が入力されおいる必芁があるフォヌムを提出するためのもの、1぀はナヌザヌが戻っおきお、埌で埋めるこずができるようにフォヌムを保存するためのもの、1぀は完党にフォヌムをキャンセルするためのものである。

<form action="editor.cgi" method="post">
 <p><label>Name: <input required name=fn></label></p>
 <p><label>Essay: <textarea required name=essay></textarea></label></p>
 <p><input type=submit name=submit value="Submit essay"></p>
 <p><input type=submit formnovalidate name=save value="Save essay"></p>
 <p><input type=submit formnovalidate name=cancel value="Cancel"></p>
</form>

The action IDL attribute must reflect the content attribute of the same name, except that on getting, when the content attribute is missing or its value is the empty string, the document's address must be returned instead. The target IDL attribute must reflect the content attribute of the same name. The method and enctype IDL attributes must reflect the respective content attributes of the same name, limited to only known values. The encoding IDL attribute must reflect the enctype content attribute, limited to only known values. The noValidate IDL attribute must reflect the novalidate content attribute. The formAction IDL attribute must reflect the formaction content attribute, except that on getting, when the content attribute is missing or its value is the empty string, the document's address must be returned instead. The formEnctype IDL attribute must reflect the formenctype content attribute, limited to only known values. The formMethod IDL attribute must reflect the formmethod content attribute, limited to only known values. The formNoValidate IDL attribute must reflect the formnovalidate content attribute. The formTarget IDL attribute must reflect the formtarget content attribute.

4.10.19.7 フォヌムコントロヌルを自動フォヌカスするautofocus属性

autofocusコンテンツ属性は、ペヌゞが読み蟌たれるずすぐに、コントロヌルをフォヌカスするこずを著者に蚱可し、ナヌザヌが手動でメむンコントロヌルにフォヌカスするこずなしに入力をすぐに開始できるようにする。

autofocus属性は真停属性である。

芁玠の盎近の祖先オヌトフォヌカス範囲のルヌト芁玠は、芁玠のルヌト芁玠である。

䞡方がautofocus属性を指定される同じ盎近の祖先オヌトフォヌカス範囲のルヌト芁玠をも぀2぀の芁玠が存圚しおはならない。

When an element with the autofocus attribute specified is inserted into a document, user agents should run the following steps:

  1. Let target be the element's Document.

  2. If target has no browsing context, abort these steps.

  3. If target's browsing context has no top-level browsing context (e.g. it is a nested browsing context with no parent browsing context), abort these steps.

  4. If target's active sandboxing flag set has the sandboxed automatic features browsing context flag, abort these steps.

  5. If target's origin is not the same as the origin of the Document of the currently focused element in target's top-level browsing context, abort these steps.

  6. If target's origin is not the same as the origin of the active document of target's top-level browsing context, abort these steps.

  7. If the user agent has already reached the last step of this list of steps in response to an element being inserted into a Document whose top-level browsing context's active document is the same as target's top-level browsing context's active document, abort these steps.

  8. If the user has indicated (for example, by starting to type in a form control) that he does not wish focus to be changed, then optionally abort these steps.

  9. Queue a task that checks to see if the element is focusable, and if so, runs the focusing steps for that element. User agents may also change the scrolling position of the document, or perform some other action that brings the element to the user's attention. The task source for this task is the user interaction task source.

This handles the automatic focusing during document load.

Focusing the control does not imply that the user agent must focus the browser window if it has lost focus.

The autofocus IDL attribute must reflect the content attribute of the same name.

次の断片においお、文曞が読み蟌たれるずき、テキストコントロヌルにフォヌカスされる。

<input maxlength="256" name="q" value="" autofocus>
<input type="submit" value="Search">
4.10.19.8 オヌトフィルフォヌムコントロヌルautocomplete属性

ナヌザヌ゚ヌゞェントは、たずえば以前のナヌザヌ入力に基づくナヌザヌのアドレスを事前に入力するなど、ナヌザヌにフォヌムの蚘入を助けるための機胜を持぀こずもある。autocompleteコンテンツ属性は、ナヌザヌ゚ヌゞェントぞのヒントの手段に、たたは実際にそのような機胜を提䟛するかどうかに䜿甚できる。

属性が存圚する堎合は、文字列"off"にASCII倧文字・小文字䞍区別で䞀臎する倀、たたは文字列"on"にASCII倧文字・小文字䞍区別で䞀臎する単䞀トヌクンである倀を持たなければならない。

"off"キヌワヌドは、コントロヌルの入力デヌタが特にセンシティブたずえば、栞兵噚のアクティベヌションコヌドである、たたはキヌワヌドが再利甚されるこずのない倀たずえば、銀行のログむンのためのワンタむムキヌであり、したがっおナヌザヌは、倀を事前入力するためにナヌザヌ゚ヌゞェントを圓おにできる代わりに、明瀺的にデヌタを毎回入力する必芁がある、たたは文曞は独自のオヌトコンプリヌトのメカニズムを提䟛し、ナヌザヌ゚ヌゞェントに自動補完倀を提䟛したくないこずのいずれかを瀺す。

"on"キヌワヌドは、ナヌザヌ゚ヌゞェントが、オヌトコンプリヌト倀をナヌザヌに提䟛するこずを蚱可するが、ナヌザヌが入力するず予想されるだろうデヌタの皮類に぀いおのさらなる情報を提䟛しないこずを瀺す。ナヌザヌ゚ヌゞェントは、自動補完が提案する倀を決定するためにヒュヌリスティックを䜿甚する必芁があるだろう。

autocomplete属性が省略される堎合、芁玠のフォヌム所有者のautocomplete属性に関する状態に察応するデフォルト倀が"on"たたは"off"のいずれかの代わりに䜿甚される。フォヌム所有者が存圚しない堎合、倀"on"が䜿甚される。

When an element's autofill field name is "off", the user agent should not remember the control's value, and should not offer past values to the user.

In addition, when an element's autofill field name is "off", values are reset when traversing the history.

Banks frequently do not want UAs to prefill login information:

<p><label>Account: <input type="text" name="ac" autocomplete="off"></label></p>
<p><label>PIN: <input type="password" name="pin" autocomplete="off"></label></p>

When an element's autofill field name is not "off", the user agent may store the control's value, and may offer previously stored values to the user.

When the autofill field name is "on", the user agent should attempt to use heuristics to determine the most appropriate values to offer the user, e.g. based on the element's name value, the position of the element in the document's DOM, what other fields exist in the form, and so forth.

オヌトコンプリヌト機構は、あたかもナヌザヌが芁玠の倀を修正したかのようにナヌザヌ゚ヌゞェントの振るたいによっお実装されなければならず、芁玠がmutableである堎所である時間に実行されなければならない。たずえば、芁玠が文曞に挿入される盎埌、たたはナヌザヌ゚ヌゞェントが解析を停止する際。ナヌザヌ゚ヌゞェントは、は、ナヌザヌが入力したかもしれない倀を䜿甚するコントロヌルのみを事前入力しなければならない。

A user agent prefilling a form control's value must not cause that control to suffer from a type mismatch, suffer from a pattern mismatch, suffer from being too long, suffer from being too short, suffer from an underflow, suffer from an overflow, or suffer from a step mismatch. Where possible given the control's constraints, user agents must use the format given as canonical in the aforementioned table. Where it's not possible for the canonical format to be used, user agents should use heuristics to attempt to convert values so that they can be used.

A user agent may allow the user to override an element's autofill field name, e.g. to change it from "off" to "on" to allow values to be remembered and prefilled despite the page author's objections, or to always "off", never remembering values. However, user agents should not allow users to trivially override the autofill field name from "off" to "on" or other values, as there are significant security implications for the user if all values are always remembered, regardless of the site's preferences.

The autocomplete IDL attribute, on getting, must return the element's IDL-exposed autofill value, and on setting, must reflect the content attribute of the same name.

4.10.20 テキストフィヌルドセレクションのためのAPI

inputおよびtextarea芁玠はセレクションを扱うDOMむンタヌフェヌスで以䞋のメンバヌを定矩する

  void select();
           attribute unsigned long selectionStart;
           attribute unsigned long selectionEnd;
           attribute DOMString selectionDirection;
  void setRangeText(DOMString replacement);
  void setRangeText(DOMString replacement, unsigned long start, unsigned long end, optional SelectionMode selectionMode = "preserve");
  void setSelectionRange(unsigned long start, unsigned long end, optional DOMString direction = "preserve");

setRangeTextメ゜ッドは以䞋の列挙型を䜿甚する

enum SelectionMode {
  "select",
  "start",
  "end",
  "preserve" // default
};

これらメ゜ッドず属性は、inputおよびtextareaテキストフィヌルドのセレクションを公開し制埡する。

element . select()

テキストフィヌルドにおけるすべおを遞択する。

element . selectionStart [ = value ]

セレクションの開始オフセットを返す。

セレクションの開始を倉曎する蚭定が可胜である。

element . selectionEnd [ = value ]

セレクションの終了オフセットを返す。

セレクションの終了を倉曎する蚭定が可胜である。

element . selectionDirection [ = value ]

セレクションの珟圚の方向を返す。

セレクションの珟圚の方向を倉曎する蚭定が可胜である。

可胜な倀は、"forward"、"backward"、"none"である。

element . setSelectionRange(start, end [, direction] )

指定された方向に指定された郚分列をカバヌするために遞択を倉曎する。方向が省略された堎合、方向がプラットフォヌムのデフォルトなしたたは前方になるようにリセットされる。

element . setRangeText(replacement [, start, end [, selectionMode ] ] )

新しいテキストずずもにテキストの範囲を眮換する。startおよびend匕数が提䟛されない堎合、範囲は遞択されるこずが想定される。

最埌の匕数は、テキストを亀換した埌に遞択が蚭定されるべきであるかを決定する。可胜な倀は次のずおり

"select"
新しく挿入されたテキストを遞択する。
"start"
挿入されたテキストの前のアむテムのみを遞択する。
"end"
遞択されたテキストの埌のアむテムのみを遞択する。
"preserve"
遞択を保持しようずする。これはデフォルトである。

For input elements, calling these methods while they don't apply, and getting or setting these attributes while they don't apply, must throw an InvalidStateError exception. Otherwise, they must act as described below.

For input elements, these methods and attributes must operate on the element's value. For textarea elements, these methods and attributes must operate on the element's raw value.

Where possible, user interface features for changing the text selection in input and textarea elements must be implemented in terms of the DOM API described in this section, so that, e.g., all the same events fire.

The selections of input and textarea elements have a direction, which is either forward, backward, or none. This direction is set when the user manipulates the selection. The exact meaning of the selection direction depends on the platform.

On Windows, the direction indicates the position of the caret relative to the selection: a forward selection has the caret at the end of the selection and a backward selection has the caret at the start of the selection. Windows has no none direction. On Mac, the direction indicates which end of the selection is affected when the user adjusts the size of the selection using the arrow keys with the Shift modifier: the forward direction means the end of the selection is modified, and the backwards direction means the start of the selection is modified. The none direction is the default on Mac, it indicates that no particular direction has yet been selected. The user sets the direction implicitly when first adjusting the selection, based on which directional arrow key was used.

The select() method must cause the contents of the text field to be fully selected, with the selection direction being none, if the platform support selections with the direction none, or otherwise forward. The user agent must then queue a task to fire a simple event that bubbles named select at the element, using the user interaction task source as the task source.

The selectionStart attribute must, on getting, return the offset (in logical order) to the character that immediately follows the start of the selection. If there is no selection, then it must return the offset (in logical order) to the character that immediately follows the text entry cursor.

On setting, it must act as if the setSelectionRange() method had been called, with the new value as the first argument; the current value of the selectionEnd attribute as the second argument, unless the current value of the selectionEnd is less than the new value, in which case the second argument must also be the new value; and the current value of the selectionDirection as the third argument.

The selectionEnd attribute must, on getting, return the offset (in logical order) to the character that immediately follows the end of the selection. If there is no selection, then it must return the offset (in logical order) to the character that immediately follows the text entry cursor.

On setting, it must act as if the setSelectionRange() method had been called, with the current value of the selectionStart attribute as the first argument, the new value as the second argument, and the current value of the selectionDirection as the third argument.

The selectionDirection attribute must, on getting, return the string corresponding to the current selection direction: if the direction is forward, "forward"; if the direction is backward, "backward"; and otherwise, "none".

On setting, it must act as if the setSelectionRange() method had been called, with the current value of the selectionStart attribute as the first argument, the current value of the selectionEnd attribute as the second argument, and the new value as the third argument.

The setSelectionRange(start, end, direction) method must set the selection of the text field to the sequence of characters starting with the character at the startth position (in logical order) and ending with the character at the (end-1)th position. Arguments greater than the length of the value of the text field must be treated as pointing at the end of the text field. If end is less than or equal to start then the start of the selection and the end of the selection must both be placed immediately before the character with offset end. In UAs where there is no concept of an empty selection, this must set the cursor to be just before the character with offset end. The direction of the selection must be set to backward if direction is a case-sensitive match for the string "backward", forward if direction is a case-sensitive match for the string "forward" or if the platform does not support selections with the direction none, and none otherwise (including if the argument is omitted). The user agent must then queue a task to fire a simple event that bubbles named select at the element, using the user interaction task source as the task source.

The setRangeText(replacement, start, end, selectMode) method must run the following steps:

  1. If the method has only one argument, then let start and end have the values of the selectionStart attribute and the selectionEnd attribute respectively.

    Otherwise, let start, end have the values of the second and third arguments respectively.

  2. If start is greater than end, then throw an IndexSizeError exception and abort these steps.

  3. If start is greater than the length of the value of the text field, then set it to the length of the value of the text field.

  4. If end is greater than the length of the value of the text field, then set it to the length of the value of the text field.

  5. Let selection start be the current value of the selectionStart attribute.

  6. Let selection end be the current value of the selectionEnd attribute.

  7. If start is less than end, delete the sequence of characters starting with the character at the startth position (in logical order) and ending with the character at the (end-1)th position.

  8. Insert the value of the first argument into the text of the value of the text field, immediately before the startth character.

  9. Let new length be the length of the value of the first argument.

  10. Let new end be the sum of start and new length.

  11. Run the appropriate set of substeps from the following list:

    If the fourth argument's value is "select"

    Let selection start be start.

    Let selection end be new end.

    If the fourth argument's value is "start"

    Let selection start and selection end be start.

    If the fourth argument's value is "end"

    Let selection start and selection end be new end.

    If the fourth argument's value is "preserve" (the default)
    1. Let old length be end minus start.

    2. Let delta be new length minus old length.

    3. If selection start is greater than end, then increment it by delta. (If delta is negative, i.e. the new text is shorter than the old text, then this will decrease the value of selection start.)

      Otherwise: if selection start is greater than start, then set it to start. (This snaps the start of the selection to the start of the new text if it was in the middle of the text that it replaced.)

    4. If selection end is greater than end, then increment it by delta in the same way.

      Otherwise: if selection end is greater than start, then set it to new end. (This snaps the end of the selection to the end of the new text if it was in the middle of the text that it replaced.)

  12. Set the selection of the text field to the sequence of characters starting with the character at the selection startth position (in logical order) and ending with the character at the (selection end-1)th position. In UAs where there is no concept of an empty selection, this must set the cursor to be just before the character with offset end. The direction of the selection must be set to forward if the platform does not support selections with the direction none, and none otherwise.

  13. Queue a task to fire a simple event that bubbles named select at the element, using the user interaction task source as the task source.

All elements to which this API applies have either a selection or a text entry cursor position at all times (even for elements that are not being rendered). User agents should follow platform conventions to determine their initial state.

U+200D ZERO WIDTH JOINERのような、䞍可芖のレンダリングをずもなう文字は、䟝然ずしお文字ずしおカりントされる。したがっお、たずえば遞択は単に䞍可芖の文字を含めるこずができ、テキスト挿入カヌ゜ルは片偎たたはそのような文字の別のものに配眮できる。

珟圚遞択されおいるテキストを取埗するためには、次のJavaScriptで十分である

var selectionText = control.value.substring(control.selectionStart, control.selectionEnd);

ここで、controlはinputたたはtextarea芁玠である。

テキストの遞択範囲を維持する䞀方で、テキストコントロヌルの開始時にテキストを远加するには、3぀の属性が保持されなければならない

var oldStart = control.selectionStart;
var oldEnd = control.selectionEnd;
var oldDirection = control.selectionDirection;
var prefix = "http://";
control.value = prefix + control.value;
control.setSelectionRange(oldStart + prefix.length, oldEnd + prefix.length, oldDirection);

ここで、controlはinputたたはtextarea芁玠である。

4.10.21 制玄

4.10.21.1 定矩

A submittable element is a candidate for constraint validation except when a condition has barred the element from constraint validation. (For example, an element is barred from constraint validation if it is an object element.)

An element can have a custom validity error message defined. Initially, an element must have its custom validity error message set to the empty string. When its value is not the empty string, the element is suffering from a custom error. It can be set using the setCustomValidity() method. The user agent should use the custom validity error message when alerting the user to the problem with the control.

An element can be constrained in various ways. The following is the list of validity states that a form control can be in, making the control invalid for the purposes of constraint validation. (The definitions below are non-normative; other parts of this specification define more precisely when each state applies or does not.)

Suffering from being missing

When a control has no value but has a required attribute (input required, select required, textarea required), or, in the case of an element in a radio button group, any of the other elements in the group has a required attribute.

Suffering from a type mismatch

When a control that allows arbitrary user input has a value that is not in the correct syntax (E-mail, URL).

Suffering from a pattern mismatch

When a control has a value that doesn't satisfy the pattern attribute.

Suffering from being too long

When a control has a value that is too long for the form control maxlength attribute (input maxlength, textarea maxlength).

Suffering from being too short

When a control has a value that is too short for the form control minlength attribute (input minlength, textarea minlength).

Suffering from an underflow

When a control has a value that is too low for the min attribute.

Suffering from an overflow

When a control has a value that is too high for the max attribute.

Suffering from a step mismatch

When a control has a value that doesn't fit the rules given by the step attribute.

Suffering from bad input

When a control has incomplete input and the user agent does not think the user ought to be able to submit the form in its current state.

Suffering from a custom error

When a control's custom validity error message (as set by the element's setCustomValidity() method) is not the empty string.

An element can still suffer from these states even when the element is disabled; thus these states can be represented in the DOM even if validating the form during submission wouldn't indicate a problem to the user.

An element satisfies its constraints if it is not suffering from any of the above validity states.

4.10.21.2 Constraint validation

When the user agent is required to statically validate the constraints of form element form, it must run the following steps, which return either a positive result (all the controls in the form are valid) or a negative result (there are invalid controls) along with a (possibly empty) list of elements that are invalid and for which no script has claimed responsibility:

  1. Let controls be a list of all the submittable elements whose form owner is form, in tree order.

  2. Let invalid controls be an initially empty list of elements.

  3. For each element field in controls, in tree order, run the following substeps:

    1. If field is not a candidate for constraint validation, then move on to the next element.

    2. Otherwise, if field satisfies its constraints, then move on to the next element.

    3. Otherwise, add field to invalid controls.

  4. If invalid controls is empty, then return a positive result and abort these steps.

  5. Let unhandled invalid controls be an initially empty list of elements.

  6. For each element field in invalid controls, if any, in tree order, run the following substeps:

    1. Fire a simple event named invalid that is cancelable at field.

    2. If the event was not canceled, then add field to unhandled invalid controls.

  7. Return a negative result with the list of elements in the unhandled invalid controls list.

If a user agent is to interactively validate the constraints of form element form, then the user agent must run the following steps:

  1. Statically validate the constraints of form, and let unhandled invalid controls be the list of elements returned if the result was negative.

  2. If the result was positive, then return that result and abort these steps.

  3. Report the problems with the constraints of at least one of the elements given in unhandled invalid controls to the user. User agents may focus one of those elements in the process, by running the focusing steps for that element, and may change the scrolling position of the document, or perform some other action that brings the element to the user's attention. User agents may report more than one constraint violation. User agents may coalesce related constraint violation reports if appropriate (e.g. if multiple radio buttons in a group are marked as required, only one error need be reported). If one of the controls is not being rendered (e.g. it has the hidden attribute set) then user agents may report a script error.

  4. Return a negative result.

4.10.21.3 制玄怜蚌API
element . willValidate

フォヌムが送信される際に芁玠が認蚌される堎合trueを返し、そうでなければfalseを返す。

element . setCustomValidity(message)

芁玠の怜蚌に倱敗するように、カスタム゚ラヌを蚭定する。䞎えられたメッセヌゞは、ナヌザヌに問題を報告する際にナヌザヌに衚瀺されるメッセヌゞである。

匕数が空文字列である堎合、カスタム゚ラヌをクリアする。

element . validity . valueMissing

芁玠が倀を持たないが必須フィヌルドである堎合trueを返し、そうでなければfalseを返す。

element . validity . typeMismatch

芁玠の倀が正しい構文でない堎合trueを返し、そうでなければfalseを返す。

element . validity . patternMismatch

芁玠の倀が提䟛されたパタヌンずマッチしない堎合trueを返し、そうでなければfalseを返す。

element . validity . tooLong

芁玠の倀が提䟛された最倧長さより長い堎合trueを返し、そうでなければfalseを返す。

element . validity . tooShort

芁玠の倀が空文字列ではなく、提䟛された最小長さより短い堎合trueを返し、そうでなければfalseを返す。

element . validity . rangeUnderflow

芁玠の倀が提䟛された最小倀より短い堎合trueを返し、そうでなければfalseを返す。

element . validity . rangeOverflow

芁玠の倀が提䟛された最倧倀より長い堎合trueを返し、そうでなければfalseを返す。

element . validity . stepMismatch

芁玠の倀がstep属性によっお䞎えられる芏則に合臎しない堎合trueを返し、そうでなければfalseを返す。

element . validity . badInput

ナヌザヌ゚ヌゞェントが倀に倉換できないナヌザヌむンタヌフェヌスで入力をナヌザヌが提䟛される堎合trueを返し、そうでなければfalseを返す。

element . validity . customError

芁玠がカスタム゚ラヌを持぀堎合trueを返し、そうでなければfalseを返す。

element . validity . valid

芁玠の倀が劥圓性問題を持たない堎合trueを返し、そうでなければfalseを返す。

valid = element . checkValidity()

芁玠の倀が劥圓性問題を持たない堎合trueを返し、そうでなければfalseを返す。埌者の堎合芁玠でinvalidむベントを発火する。

element . validationMessage

芁玠が劥圓性に察しおチェックされた堎合、ナヌザヌに衚瀺される゚ラヌメッセヌゞを返す。

The willValidate attribute must return true if an element is a candidate for constraint validation, and false otherwise (i.e. false if any conditions are barring it from constraint validation).

The setCustomValidity(message), when invoked, must set the custom validity error message to the value of the given message argument.

次の䟋においお、スクリプトは倀が線集されるたびにフォヌムコントロヌルの倀をチェックし、か぀劥圓な倀でない堎合はい぀でも、適切なメッセヌゞを蚭定するためにsetCustomValidity()メ゜ッドを䜿甚する。

<label>Feeling: <input name=f type="text" oninput="check(this)"></label>
<script>
 function check(input) {
   if (input.value == "good" ||
       input.value == "fine" ||
       input.value == "tired") {
     input.setCustomValidity('"' + input.value + '" is not a feeling.');
   } else {
     // input is fine -- reset the error message
     input.setCustomValidity('');
   }
 }
</script>

The validity attribute must return a ValidityState object that represents the validity states of the element. This object is live, and the same object must be returned each time the element's validity attribute is retrieved.

interface ValidityState {
  readonly attribute boolean valueMissing;
  readonly attribute boolean typeMismatch;
  readonly attribute boolean patternMismatch;
  readonly attribute boolean tooLong;
  readonly attribute boolean tooShort;
  readonly attribute boolean rangeUnderflow;
  readonly attribute boolean rangeOverflow;
  readonly attribute boolean stepMismatch;
  readonly attribute boolean badInput;
  readonly attribute boolean customError;
  readonly attribute boolean valid;
};

A ValidityState object has the following attributes. On getting, they must return true if the corresponding condition given in the following list is true, and false otherwise.

valueMissing

The control is suffering from being missing.

typeMismatch

The control is suffering from a type mismatch.

patternMismatch

The control is suffering from a pattern mismatch.

tooLong

The control is suffering from being too long.

tooShort

The control is suffering from being too short.

rangeUnderflow

The control is suffering from an underflow.

rangeOverflow

The control is suffering from an overflow.

stepMismatch

The control is suffering from a step mismatch.

badInput

The control is suffering from bad input.

customError

The control is suffering from a custom error.

valid

None of the other conditions are true.

When the checkValidity() method is invoked, if the element is a candidate for constraint validation and does not satisfy its constraints, the user agent must fire a simple event named invalid that is cancelable (but in this case has no default action) at the element and return false. Otherwise, it must only return true without doing anything else.

The validationMessage attribute must return the empty string if the element is not a candidate for constraint validation or if it is one but it satisfies its constraints; otherwise, it must return a suitably localized message that the user agent would show the user if this were the only form control with a validity constraint problem. If the user agent would not actually show a textual message in such a situation (e.g. it would show a graphical cue instead), then the attribute must return a suitably localized message that expresses (one or more of) the validity constraint(s) that the control does not satisfy. If the element is a candidate for constraint validation and is suffering from a custom error, then the custom validity error message should be present in the return value.

4.10.21.4 セキュリティヌ

サヌバは、クラむアント偎の怜蚌に䟝存すべきではない。クラむアント偎の怜蚌は、悪意あるナヌザヌによっお意図的にバむパスされ、叀いナヌザヌ゚ヌゞェントたたは、これらの機胜を実装しない自動化ツヌルのナヌザヌによっお意図せずに回避されうる。制玄怜蚌機胜は、あらゆる皮類のセキュリティヌメカニズムを提䟛するこずでなく、ナヌザヌの利䟿性を向䞊させるこずのみを意図する。

4.10.22 フォヌムの送信

4.10.22.1 Introduction

この節は非芏範的である。

フォヌムが送信される際、フォヌム内のデヌタはenctypeで指定した構造䜓に倉換され、指定したメ゜ッドを䜿甚するアクションで指定した宛先に送信される。

たずえば、次のような圢匏をずる

<form action="/find.cgi" method=get>
 <input type=text name=t>
 <input type=search name=q>
 <input type=submit>
</form>

ナヌザヌが最初のフィヌルドで"cat"および2番目で"猫"ず入力し、次に送信ボタンを抌す堎合、ナヌザヌ゚ヌゞェントは/find.cgi?t=cats&q=furを読み蟌む。

䞀方、このフォヌムを考えおみる

<form action="/find.cgi" method=post enctype="multipart/form-data">
 <input type=text name=t>
 <input type=search name=q>
 <input type=submit>
</form>

同じナヌザヌ入力を考えるず、提出䞊の結果はかなり異なるナヌザヌ゚ヌゞェントは、次のテキストのような゚ンティティボディずしお、代わりに指定されたURLにHTTP POSTを行う。

------kYFrd4jNJEgCervE
Content-Disposition: form-data; name="t"

cats
------kYFrd4jNJEgCervE
Content-Disposition: form-data; name="q"

fur
------kYFrd4jNJEgCervE--
4.10.22.2 Implicit submission

A form element's default button is the first submit button in tree order whose form owner is that form element.

If the user agent supports letting the user submit a form implicitly (for example, on some platforms hitting the "enter" key while a text field is focused implicitly submits the form), then doing so for a form whose default button has a defined activation behavior must cause the user agent to run synthetic click activation steps on that default button.

Consequently, if the default button is disabled, the form is not submitted when such an implicit submission mechanism is used. (A button has no activation behavior when disabled.)

There are pages on the Web that are only usable if there is a way to implicitly submit forms, so user agents are strongly encouraged to support this.

If the form has no submit button, then the implicit submission mechanism must do nothing if the form has more than one field that blocks implicit submission, and must submit the form element from the form element itself otherwise.

For the purpose of the previous paragraph, an element is a field that blocks implicit submission of a form element if it is an input element whose form owner is that form element and whose type attribute is in one of the following states: Text, Search, URL, Telephone, E-mail, Password, Date, Time, Number

4.10.22.3 Form submission algorithm

When a form element form is submitted from an element submitter (typically a button), optionally with a submitted from submit() method flag set, the user agent must run the following steps:

  1. Let form document be the form's Document.

  2. If form document has no associated browsing context or its active sandboxing flag set has its sandboxed forms browsing context flag set, then abort these steps without doing anything.

  3. Let form browsing context be the browsing context of form document.

  4. If the submitted from submit() method flag is not set, and the submitter element's no-validate state is false, then interactively validate the constraints of form and examine the result: if the result is negative (the constraint validation concluded that there were invalid fields and probably informed the user of this) then fire a simple event named invalid at the form element and then abort these steps.

  5. If the submitted from submit() method flag is not set, then fire a simple event that bubbles and is cancelable named submit, at form. If the event's default action is prevented (i.e. if the event is canceled) then abort these steps. Otherwise, continue (effectively the default action is to perform the submission).

  6. Let form data set be the result of constructing the form data set for form in the context of submitter.

  7. Let action be the submitter element's action.

  8. If action is the empty string, let action be the document's address of the form document.

  9. Resolve the URL action, relative to the submitter element. If this fails, abort these steps.

  10. Let action be the resulting absolute URL.

  11. Let action components be the resulting parsed URL.

  12. Let scheme be the scheme of the resulting parsed URL.

  13. Let enctype be the submitter element's enctype.

  14. Let method be the submitter element's method.

  15. Let target be the submitter element's target.

  16. If the user indicated a specific browsing context to use when submitting the form, then let target browsing context be that browsing context. Otherwise, apply the rules for choosing a browsing context given a browsing context name using target as the name and form browsing context as the context in which the algorithm is executed, and let target browsing context be the resulting browsing context.

  17. If target browsing context was created in the previous step, or, alternatively, if the form document has not yet completely loaded and the submitted from submit() method flag is set, then let replace be true. Otherwise, let it be false.

  18. Otherwise, select the appropriate row in the table below based on the value of scheme as given by the first cell of each row. Then, select the appropriate cell on that row based on the value of method as given in the first cell of each column. Then, jump to the steps named in that cell and defined below the table.

    GET POST
    http Mutate action URL Submit as entity body
    https Mutate action URL Submit as entity body
    ftp Get action URL Get action URL
    javascript Get action URL Get action URL
    data Get action URL Post to data:
    mailto Mail with headers Mail as body

    If scheme is not one of those listed in this table, then the behavior is not defined by this specification. User agents should, in the absence of another specification defining this, act in a manner analogous to that defined in this specification for similar schemes.

    Each form element has a planned navigation, which is either null or a task; when the form is first created, its planned navigation must be set to null. In the behaviours described below, when the user agent is required to plan to navigate to a particular resource destination, it must run the following steps:

    1. If the form has a non-null planned navigation, remove it from its task queue.

    2. Let the form's planned navigation be a new task that consists of running the following steps:

      1. Let the form's planned navigation be null.

      2. Navigate target browsing context to the particular resource destination. If replace is true, then target browsing context must be navigated with replacement enabled.

      For the purposes of this task, target browsing context and replace are the variables that were set up when the overall form submission algorithm was run, with their values as they stood when this planned navigation was queued.

    3. Queue the task that is the form's new planned navigation.

      The task source for this task is the DOM manipulation task source.

    The behaviors are as follows:

    Mutate action URL

    Let query be the result of encoding the form data set using the application/x-www-form-urlencoded encoding algorithm, interpreted as a US-ASCII string.

    Set parsed action's query component to query.

    Let destination be a new URL formed by applying the URL serializer algorithm to parsed action.

    Plan to navigate to destination.

    Submit as entity body

    Let entity body be the result of encoding the form data set using the appropriate form encoding algorithm.

    Let MIME type be determined as follows:

    If enctype is application/x-www-form-urlencoded
    Let MIME type be "application/x-www-form-urlencoded".
    If enctype is multipart/form-data
    Let MIME type be the concatenation of the string "multipart/form-data;", a U+0020 SPACE character, the string "boundary=", and the multipart/form-data boundary string generated by the multipart/form-data encoding algorithm.
    If enctype is text/plain
    Let MIME type be "text/plain".

    Otherwise, plan to navigate to action using the HTTP method given by method and with entity body as the entity body, of type MIME type.

    Get action URL

    Plan to navigate to action.

    The form data set is discarded.

    Post to data:

    Let data be the result of encoding the form data set using the appropriate form encoding algorithm.

    If action contains the string "%%%%" (four U+0025 PERCENT SIGN characters), then percent encode all bytes in data that, if interpreted as US-ASCII, are not characters in the URL default encode set, and then, treating the result as a US-ASCII string, UTF-8 percent encode all the U+0025 PERCENT SIGN characters in the resulting string and replace the first occurrence of "%%%%" in action with the resulting doubly-escaped string. [URL]

    Otherwise, if action contains the string "%%" (two U+0025 PERCENT SIGN characters in a row, but not four), then UTF-8 percent encode all characters in data that, if interpreted as US-ASCII, are not characters in the URL default encode set, and then, treating the result as a US-ASCII string, replace the first occurrence of "%%" in action with the resulting escaped string. [URL]

    Plan to navigate to the potentially modified action (which will be a data: URL).

    Mail with headers

    Let headers be the resulting encoding the form data set using the application/x-www-form-urlencoded encoding algorithm, interpreted as a US-ASCII string.

    Replace occurrences of "+" (U+002B) characters in headers with the string "%20".

    Let destination consist of all the characters from the first character in action to the character immediately before the first "?" (U+003F) character, if any, or the end of the string if there are none.

    Append a single "?" (U+003F) character to destination.

    Append headers to destination.

    Plan to navigate to destination.

    Mail as body

    Let body be the resulting of encoding the form data set using the appropriate form encoding algorithm and then percent encoding all the bytes in the resulting byte string that, when interpreted as US-ASCII, are not characters in the URL default encode set. [URL]

    Let destination have the same value as action.

    If destination does not contain a "?" (U+003F) character, append a single "?" (U+003F) character to destination. Otherwise, append a single U+0026 AMPERSAND character (&).

    Append the string "body=" to destination.

    Append body, interpreted as a US-ASCII string, to destination.

    Plan to navigate to destination.

    The appropriate form encoding algorithm is determined as follows:

    If enctype is application/x-www-form-urlencoded
    Use the application/x-www-form-urlencoded encoding algorithm.
    If enctype is multipart/form-data
    Use the multipart/form-data encoding algorithm.
    If enctype is text/plain
    Use the text/plain encoding algorithm.
4.10.22.4 Constructing the form data set

The algorithm to construct the form data set for a form form optionally in the context of a submitter submitter is as follows. If not specified otherwise, submitter is null.

  1. Let controls be a list of all the submittable elements whose form owner is form, in tree order.

  2. Let the form data set be a list of name-value-type tuples, initially empty.

  3. Loop: For each element field in controls, in tree order, run the following substeps:

    1. If any of the following conditions are met, then skip these substeps for this element:

      • The field element has a datalist element ancestor.
      • The field element is disabled.
      • The field element is a button but it is not submitter.
      • The field element is an input element whose type attribute is in the Checkbox state and whose checkedness is false.
      • The field element is an input element whose type attribute is in the Radio Button state and whose checkedness is false.
      • The field element is not an input element whose type attribute is in the Image Button state, and either the field element does not have a name attribute specified, or its name attribute's value is the empty string.
      • The field element is an object element that is not using a plugin.

      Otherwise, process field as follows:

    2. Let type be the value of the type IDL attribute of field.

    3. If the field element is an input element whose type attribute is in the Image Button state, then run these further nested substeps:

      1. If the field element has a name attribute specified and its value is not the empty string, let name be that value followed by a single "." (U+002E) character. Otherwise, let name be the empty string.

      2. Let namex be the string consisting of the concatenation of name and a single U+0078 LATIN SMALL LETTER X character (x).

      3. Let namey be the string consisting of the concatenation of name and a single U+0079 LATIN SMALL LETTER Y character (y).

      4. The field element is submitter, and before this algorithm was invoked the user indicated a coordinate. Let x be the x-component of the coordinate selected by the user, and let y be the y-component of the coordinate selected by the user.

      5. Append an entry to the form data set with the name namex, the value x, and the type type.

      6. Append an entry to the form data set with the name namey and the value y, and the type type.

      7. Skip the remaining substeps for this element: if there are any more elements in controls, return to the top of the loop step, otherwise, jump to the end step below.

    4. Let name be the value of the field element's name attribute.

    5. If the field element is a select element, then for each option element in the select element's list of options whose selectedness is true and that is not disabled, append an entry to the form data set with the name as the name, the value of the option element as the value, and type as the type.

    6. Otherwise, if the field element is an input element whose type attribute is in the Checkbox state or the Radio Button state, then run these further nested substeps:

      1. If the field element has a value attribute specified, then let value be the value of that attribute; otherwise, let value be the string "on".

      2. Append an entry to the form data set with name as the name, value as the value, and type as the type.

    7. Otherwise, if the field element is an input element whose type attribute is in the File Upload state, then for each file selected in the input element, append an entry to the form data set with the name as the name, the file (consisting of the name, the type, and the body) as the value, and type as the type. If there are no selected files, then append an entry to the form data set with the name as the name, the empty string as the value, and application/octet-stream as the type.

    8. Otherwise, if the field element is an object element: try to obtain a form submission value from the plugin, and if that is successful, append an entry to the form data set with name as the name, the returned form submission value as the value, and the string "object" as the type.

    9. Otherwise, append an entry to the form data set with name as the name, the value of the field element as the value, and type as the type.

    10. If the element has a dirname attribute, and that attribute's value is not the empty string, then run these substeps:

      1. Let dirname be the value of the element's dirname attribute.

      2. Let dir be the string "ltr" if the directionality of the element is 'ltr', and "rtl" otherwise (i.e. when the directionality of the element is 'rtl').

      3. Append an entry to the form data set with dirname as the name, dir as the value, and the string "direction" as the type.

      An element can only have a dirname attribute if it is a textarea element or an input element whose type attribute is in either the Text state or the Search state.

  4. End: For the name of each entry in the form data set, and for the value of each entry in the form data set whose type is not "file" or "textarea", replace every occurrence of a "CR" (U+000D) character not followed by a "LF" (U+000A) character, and every occurrence of a "LF" (U+000A) character not preceded by a "CR" (U+000D) character, by a two-character string consisting of a U+000D CARRIAGE RETURN "CRLF" (U+000A) character pair.

    In the case of the value of textarea elements, this newline normalization is already performed during the conversion of the control's raw value into the control's value (which also performs any necessary line wrapping). In the case of input elements type attributes in the File Upload state, the value is not normalized.

  5. Return the form data set.

4.10.22.5 Selecting a form submission encoding

If the user agent is to pick an encoding for a form, optionally with an allow non-ASCII-compatible encodings flag set, it must run the following substeps:

  1. Let input be the value of the form element's accept-charset attribute.

  2. Let candidate encoding labels be the result of splitting input on spaces.

  3. Let candidate encodings be an empty list of character encodings.

  4. For each token in candidate encoding labels in turn (in the order in which they were found in input), get an encoding for the token and, if this does not result in failure, append the encoding to candidate encodings.

  5. If the allow non-ASCII-compatible encodings flag is not set, remove any encodings that are not ASCII-compatible character encodings from candidate encodings.

  6. If candidate encodings is empty, return UTF-8 and abort these steps.

  7. Each character encoding in candidate encodings can represent a finite number of characters. (For example, UTF-8 can represent all 1.1 million or so Unicode code points, while Windows-1252 can only represent 256.)

    For each encoding in candidate encodings, determine how many of the characters in the names and values of the entries in the form data set the encoding can represent (without ignoring duplicates). Let max be the highest such count. (For UTF-8, max would equal the number of characters in the names and values of the entries in the form data set.)

    Return the first encoding in candidate encodings that can encode max characters in the names and values of the entries in the form data set.

4.10.22.6 URL゚ンコヌドフォヌムデヌタ

このフォヌムデヌタセットの゚ンコヌディングは、いろいろな意味で垞軌を逞した奇怪な物であり、盞互運甚性に察する必芁な䞀連の芁件を導く実装事故や劥協の長幎の結果だが、決しお良い蚭蚈手法を瀺すものでない。具䜓的に、読者は、文字゚ンコヌディングずバむト配列ずの間で繰り返しそしお堎合によっおは入れ子になる倉換を䌎うねじれた现郚に现心の泚意を払うように譊告される。

The application/x-www-form-urlencoded encoding algorithm is as follows:

  1. Let result be the empty string.

  2. If the form element has an accept-charset attribute, let the selected character encoding be the result of picking an encoding for the form.

    Otherwise, if the form element has no accept-charset attribute, but the document's character encoding is an ASCII-compatible character encoding, then that is the selected character encoding.

    Otherwise, let the selected character encoding be UTF-8.

  3. Let charset be the name of the selected character encoding.

  4. For each entry in the form data set, perform these substeps:

    1. If the entry's name is "_charset_" and its type is "hidden", replace its value with charset.

    2. If the entry's type is "file", replace its value with the file's name only.

    3. For each character in the entry's name and value that cannot be expressed using the selected character encoding, replace the character by a string consisting of a U+0026 AMPERSAND character (&), a "#" (U+0023) character, one or more ASCII digits representing the Unicode code point of the character in base ten, and finally a ";" (U+003B) character.

    4. Encode the entry's name and value using the encoder for the selected character encoding. The entry's name and value are now byte strings.

    5. For each byte in the entry's name and value, apply the appropriate subsubsteps from the following list:

      If the byte is 0x20 (U+0020 SPACE if interpreted as ASCII)
      Replace the byte with a single 0x2B byte ("+" (U+002B) character if interpreted as ASCII).
      If the byte is in the range 0x2A, 0x2D, 0x2E, 0x30 to 0x39, 0x41 to 0x5A, 0x5F, 0x61 to 0x7A

      Leave the byte as is.

      そうでなければ
      1. Let s be a string consisting of a U+0025 PERCENT SIGN character (%) followed by uppercase ASCII hex digits representing the hexadecimal value of the byte in question (zero-padded if necessary).

      2. Encode the string s as US-ASCII, so that it is now a byte string.

      3. Replace the byte in question in the name or value being processed by the bytes in s, preserving their relative order.

    6. Interpret the entry's name and value as Unicode strings encoded in US-ASCII. (All of the bytes in the string will be in the range 0x00 to 0x7F; the high bit will be zero throughout.) The entry's name and value are now Unicode strings again.

    7. If the entry's name is "isindex", its type is "text", and this is the first entry in the form data set, then append the value to result and skip the rest of the substeps for this entry, moving on to the next entry, if any, or the next step in the overall algorithm otherwise.

    8. If this is not the first entry, append a single U+0026 AMPERSAND character (&) to result.

    9. Append the entry's name to result.

    10. Append a single "=" (U+003D) character to result.

    11. Append the entry's value to result.

  5. Encode result as US-ASCII and return the resulting byte stream.

application/x-www-form-urlencodedペむロヌドをデコヌドするために、次のアルゎリズムを䜿甚すべきである。このアルゎリズムは、入力ずしおU+0000からU+007Fたでの範囲内の文字のみを䜿甚するUnicode文字列で構成されるペむロヌド自身、payload、デフォルトの文字゚ンコヌディングencoding、および必芁に応じお、あたかもそれがisindexコントロヌルを含むフォヌムのために生成されおいたかのように、ペむロヌドが凊理されるこずを瀺すisindexフラグを䜿甚する。このアルゎリズムの出力は、名前ず倀のペアの゜ヌトされたリストである。isindexフラグが蚭定され、最初のコントロヌルが本物のisindexコントロヌルだった堎合、最初の名前ず倀のペアは、その名の通り、空の文字列を持぀。

䜿甚すべきどのデフォルトの文字゚ンコヌディングもケヌスバむケヌスで決定されるが、䞀般にデフォルトずしお䜿甚すべき最適な文字゚ンコヌディングは、フ自身が芋぀けられたペむロヌドを䜜成するために䜿甚されたフォヌムでペヌゞを゚ンコヌドするために䜿甚されたものである。より良いデフォルトがない限り、UTF-8が掚奚される。

isindexフラグはレガシヌにのみ䜿甚される。HTML文曞に適合するフォヌムは、このフラグを蚭定しおデコヌドする必芁があるペむロヌドを生成しない。

  1. stringsをU+0026 AMPERSAND文字&で厳密に文字列を分割するpayloadの結果ずする。

  2. isindexフラグが蚭定され、stringsで先頭文字列が"="U+003D文字を含たない堎合、stringsの先頭文字列の開始に"="U+003D文字を挿入する。

  3. pairsを名前ず倀のペアの空リストにする。

  4. strings内の各文字列stringに察しお、以䞋のサブステップを実行する。

    1. stringが"="U+003D文字を含む堎合、そのnameをstringの先頭からstringの郚分文字列であるが、その最初の"="U+003D文字を陀くこずができ、もしあれば、そのvalueを最初の文字から郚分文字列ずし、その埌stringの末尟に最初の"="U+003D文字ずする。最初の"=" U+003D文字が最初の文字である堎合、nameは空文字列になる。それが最埌の文字である堎合、valueは空文字列になる。

      そうでなければ、stringは"="U+003D文字を含たない。nameにstringの倀を持たせ、valueを空文字列にする。

    2. nameおよびvalueのすべおの"+"U+002B文字をU+0020 SPACE文字に眮換する。

    3. nameおよびvalueでのすべおの゚スケヌプを゚スケヌプによっお衚される文字に眮換する。この眮換は、ほずんどの堎合再垰的でない。

      ゚スケヌプは"%"U+0025文字の埌に続く2぀のアスキヌ16進数である。

      ゚スケヌプで衚珟される文字は、コヌドポむントが16進数0から255たでの範囲内ずしお解釈される、"%"U+0025文字の埌に2文字の倀に等しいUnicode文字である。

      よっお、たずえば、文字列"A%2BC"は"A+C"になる。同様に、文字列"100%25AA%21"は文字列"100%AA!"になる。

    4. nameおよびvalue文字列をISO-8859-1におけるバむト衚珟に倉換するすなわち、盎接バむト倀にコヌドポむントをマッピングし、バむト文字列をUnicode文字列に倉換する。

    5. nameおよびvalueからなるペアにpairsを远加する。

  5. pairsの名前ず倀のペアのいずれかが、ある堎合は、US-ASCIIで゚ンコヌドされた文字列"_charset_"から成る名前コンポヌネント、およびUS-ASCIIずしおデコヌドされる際に最初のペアの倀コンポヌネントを持ち、サポヌトされる文字゚ンコヌディングの名前である堎合、encodingをその文字゚ンコヌディングデフォルトで眮換するアルゎリズムに枡すずする。

  6. ゚ンコヌディングencodingに埓っおバむトを解釈するこずによっお、Unicodeぞpairsのそれぞれの名前ず倀の、名前ず倀のコンポヌネントを倉換する。

  7. pairsを返す。

application/x-www-form-urlencodedMIMEタむプ䞊のパラメヌタは無芖される。特に、このMIMEタむプはcharsetパラメヌタをサポヌトしない。

4.10.22.7 マルチパヌトフォヌムデヌタ

The multipart/form-data encoding algorithm is as follows:

  1. Let result be the empty string.

  2. If the algorithm was invoked with an explicit character encoding, let the selected character encoding be that encoding. (This algorithm is used by other specifications, which provide an explicit character encoding to avoid the dependency on the form element described in the next paragraph.)

    Otherwise, if the form element has an accept-charset attribute, let the selected character encoding be the result of picking an encoding for the form.

    Otherwise, if the form element has no accept-charset attribute, but the document's character encoding is an ASCII-compatible character encoding, then that is the selected character encoding.

    Otherwise, let the selected character encoding be UTF-8.

  3. Let charset be the name of the selected character encoding.

  4. For each entry in the form data set, perform these substeps:

    1. If the entry's name is "_charset_" and its type is "hidden", replace its value with charset.

    2. For each character in the entry's name and value that cannot be expressed using the selected character encoding, replace the character by a string consisting of a U+0026 AMPERSAND character (&), a "#" (U+0023) character, one or more ASCII digits representing the Unicode code point of the character in base ten, and finally a ";" (U+003B) character.

  5. Encode the (now mutated) form data set using the rules described by RFC 2388, Returning Values from Forms: multipart/form-data, and return the resulting byte stream. [RFC2388]

    Each entry in the form data set is a field, the name of the entry is the field name and the value of the entry is the field value.

    The order of parts must be the same as the order of fields in the form data set. Multiple entries with the same name must be treated as distinct fields.

    In particular, this means that multiple files submitted as part of a single <input type=file multiple> element will result in each file having its own field; the "sets of files" feature ("multipart/mixed") of RFC 2388 is not used.

    The parts of the generated multipart/form-data resource that correspond to non-file fields must not have a Content-Type header specified. Their names and values must be encoded using the character encoding selected above (field names in particular do not get converted to a 7-bit safe encoding as suggested in RFC 2388).

    File names included in the generated multipart/form-data resource (as part of file fields) must use the character encoding selected above, though the precise name may be approximated if necessary (e.g. newlines could be removed from file names, quotes could be changed to "%22", and characters not expressible in the selected character encoding could be replaced by other characters). User agents must not use the RFC 2231 encoding suggested by RFC 2388.

    The boundary used by the user agent in generating the return value of this algorithm is the multipart/form-data boundary string. (This value is used to generate the MIME type of the form submission payload generated by this algorithm.)

multipart/form-dataのペむロヌドを解釈する方法の詳现に぀いおは、RFC2388を参照のこず。[RFC2388]

4.10.22.8 プレヌンテキストのフォヌムデヌタ

The text/plain encoding algorithm is as follows:

  1. Let result be the empty string.

  2. If the form element has an accept-charset attribute, let the selected character encoding be the result of picking an encoding for the form, with the allow non-ASCII-compatible encodings flag unset.

    Otherwise, if the form element has no accept-charset attribute, then that is the selected character encoding.

  3. Let charset be the name of the selected character encoding.

  4. If the entry's name is "_charset_" and its type is "hidden", replace its value with charset.

  5. If the entry's type is "file", replace its value with the file's name only.

  6. For each entry in the form data set, perform these substeps:

    1. Append the entry's name to result.

    2. Append a single "=" (U+003D) character to result.

    3. Append the entry's value to result.

    4. Append a "CR" (U+000D) "LF" (U+000A) character pair to result.

  7. Encode result using the encoder for the selected character encoding and return the resulting byte stream.

text/plain圢匏を䜿甚するペむロヌドは、人間可読であるこずを意図される。圢匏は䞍明瞭であるたずえば、倀の末尟の改行ず倀でのリテラルの改行を区別する方法はないので、これらはコンピュヌタによっお確実に解釈されない。

4.10.23 Resetting a form

When a form element form is reset, the user agent must fire a simple event named reset, that bubbles and is cancelable, at form, and then, if that event is not canceled, must invoke the reset algorithm of each resettable element whose form owner is form.

Each resettable element defines its own reset algorithm. Changes made to form controls as part of these algorithms do not count as changes caused by the user (and thus, e.g., do not cause input events to fire).