* form 要素 onreset 属性 (HTML, XHTML 1)
[1] [[HTML]] の [CODE(HTMLe)[[[form]]]] 要素の
[DFN[[CODE(HTMLa)[onreset]] 属性]]は、
[[フォーム]]が[[再設定]]される時に発生する[[事象]]に関する[[内在事象]]属性です。

[2] 仕様書:
- [[HTML 4]]
-- [CODE(HTMLa)[onreset]] 属性
<IW:HTML4:"interact/scripts.html#adef-onreset">

[[#comment]]

** 代替

[3] 内在事象属性は[[表現と構造の分離]]の原則に反するので、
好ましくないと考える人もいます。また、 [[DOM 0]]
に基づく古い設計です。

代わりに、 [CODE(HTMLe)[[[script]]]] 要素などにより関連付けたスクリプト内で
[[DOM 2]] 以上の[[事象]]に関するメソッド等が利用できます。
DOM 水準 2 や DOM 水準 3 はこの属性に対応する
DOM の事象 [CODE(DOM)[[VAR[ev:]][[reset]]]] を用意しています。

[[#comment]]

** 属性値

[4] この属性の値は [CODE(SGML)[%[[Script]]]] です。 [[SGML]]
的には [CODE(SGML)[[[CDATA]]]] です。
自称が発生したときに実行するスクリプトの code
を記述します。[[スクリプト言語]]は、
[CODE(HTTP)[[[Content-Script-Type]]]] によります。

[5] この属性は省略可能です。

* 関連

[7] 定義上、 [CODE(HTMLe)[[[fieldset]]]] が再設定されるときには
[CODE(DOMe)@en[reset]] [[事象]]は発生しません[DEL[し、 [CODE(HTMLe)[[[fieldset]]]] 要素に [CODE(HTMLa)@en[onreset]] [[属性]]を指定することはできません]]。
また、個々のフォーム[[制御子]]ではなく [CODE(HTMLe)[[[form]]]]
要素の属性であることにも注意してください。

* 歴史

- [6] ''Alertbox: リセットとキャンセルボタン(2000年4月16日)'' <http://www.usability.gr.jp/alertbox/20000416.html>

[13] [CITE[猫式Webメモ]] <http://d.hatena.ne.jp/nekoshiki/20040312#p2>

[14] [CITE@en[Web Applications 1.0 r7609     Mostly, browsers seem to make these events bubble.]]
( ([TIME[2012-12-30 12:38:00 +09:00]] 版))
<http://html5.org/tools/web-apps-tracker?from=7608&to=7609>

[15] [CITE@en-GB-x-Hixie[Web Forms 2.0]]
([TIME[2009-01-05 20:07:15 +09:00]] 版)
<http://www.whatwg.org/specs/web-forms/current-work/#additions>

[8] [CITE@en[Web Applications 1.0 r5580       Missed .onreset somehow.Fixing http://www.w3.org/Bugs/Public/show_bug.cgi?id=10892]]
( ([TIME[2010-10-05 09:03:00 +09:00]] 版))
<http://html5.org/tools/web-apps-tracker?from=5579&to=5580>

[9] [CITE@en[Web Applications 1.0 r8718     Make sure reset() can't fire a popup]]
( ([TIME[2014-08-27 07:21:00 +09:00]] 版))
<http://html5.org/r/8718>

[10] [CITE@en[Web Applications 1.0 r8886  Make sure <textarea> is reset when you parse the end tag, since otherwise it wouldn't actually ever work...]]
([TIME[2015-03-05 08:08:00 +09:00]] 版)
<https://html5.org/r/8886>

[11] [CITE@en[Resetting a textarea should reset its dirty value flag · whatwg/html@d0711b0]]
([TIME[2016-03-24 15:26:17 +09:00]] 版)
<https://github.com/whatwg/html/commit/d0711b022b24294340508357c91ce5687b998b7d>

[12] [CITE@en[Editorial: clarify reset the form owner's first step · whatwg/html@6e5ecb0]]
([TIME[2016-03-26 12:20:27 +09:00]] 版)
<https://github.com/whatwg/html/commit/6e5ecb099faf2c1d2b375081cb9bf03e92e8f088>

* メモ

[2] reset button うざい!


[16] [CITE@en[Update textarea textContent/defaultValue/value interaction]]
([[domenic]]著, [TIME[2017-06-16 05:46:10 +09:00]])
<https://github.com/whatwg/html/commit/5afbba1cf62ee01bc6af3fd220d01f3f7591a0fc>

[17] [CITE@en[Textarea defaultValue handling doesn't really match UAs (who don't match each other) when there are child elements · Issue #2752 · whatwg/html]]
([TIME[2017-06-29 17:20:01 +09:00]])
<https://github.com/whatwg/html/issues/2752>

[18] [CITE@en[Editorial: clarify a long conditional]]
([[annevk]]著, [TIME[2017-07-24 16:40:00 +09:00]])
<https://github.com/whatwg/html/commit/dfb3f61140e28a10e1a63c55d566270a4785f57b>

[19] [CITE@en[Editorial: clarify a long conditional by annevk · Pull Request #2862 · whatwg/html]]
([TIME[2017-07-28 11:45:33 +09:00]])
<https://github.com/whatwg/html/pull/2862>

[20] [CITE@en[element interaction: introduce clear algorithm concept]]
([[andreastt]]著, [TIME[2017-11-25 00:04:53 +09:00]])
<https://github.com/w3c/webdriver/commit/bc32d801107b445a3268653671732d83b3dfac1f>

[21] [CITE@en[Textarea/text input text cursor position is not updated by reset algorithm · Issue #3468 · whatwg/html]]
([TIME[2018-03-17 17:54:31 +09:00]])
<https://github.com/whatwg/html/issues/3468>