HTMLDOMフォームオブジェクト
フォームオブジェクト
Formオブジェクトは、HTMLの<form>要素を表します。
フォームオブジェクトにアクセスする
getElementById()を使用して、<form>要素にアクセスできます。
例
var x = document.getElementById("myForm");
ヒント:formsコレクションを使用して<form>要素にアクセスすることもできます。
フォームオブジェクトを作成する
document.createElement()メソッドを使用して、<form>要素を作成できます。
例
var x = document.createElement("FORM");
フォームオブジェクトコレクション
Collection | Description |
---|---|
elements | Returns a collection of all elements in a form |
フォームオブジェクトのプロパティ
Property | Description |
---|---|
acceptCharset | Sets or returns the value of the accept-charset attribute in a form |
action | Sets or returns the value of the action attribute in a form |
autocomplete | Sets or returns the value of the autocomplete attribute in a form |
encoding | Alias of enctype |
enctype | Sets or returns the value of the enctype attribute in a form |
length | Returns the number of elements in a form |
method | Sets or returns the value of the method attribute in a form |
name | Sets or returns the value of the name attribute in a form |
noValidate | Sets or returns whether the form-data should be validated or not, on submission |
target | Sets or returns the value of the target attribute in a form |
フォームオブジェクトメソッド
Method | Description |
---|---|
reset() | Resets a form |
submit() | Submits a form |
標準のプロパティとイベント
Formオブジェクトは、標準のプロパティとイベントもサポートしています。
関連ページ
HTMLチュートリアル:HTMLフォーム
JavaScriptチュートリアル:JSフォーム/検証
HTMLリファレンス:HTML <form>タグ