Inputオブジェクト

プロパティ

プロパティ 内容
value コントロールの現在の値
type 入力要素の種類
name 入力要素の名前
tabIndex 入力要素のタブ順
disabled trueのとき、要素は無効となりユーザーは入力できず、submitで送信もされない
readOnly trueのとき、読み取り専用

HTML5ではtypeが[hidden, range, color, checkbox, radio, file, button]のいずれかのとき、この設定は無視される

checked trueのとき、チェックされている (radioまたはcheckbox用)
indeterminate trueのとき、不定 (radioまたはcheckbox用)
min 最小値 (数値または日時用)
max 最大値 (数値または日時用)
step 1段階の値。"any"または正の浮動小数点数で指定。
Properties - HTMLInputElement - Web API Interfaces | MDN

value

コントロールで許可されない値が入力されると、このプロパティは空文字を返すことがあります。

type

種類 説明 対応
button A push button with no default behavior.  
checkbox A check box  
color A control for specifying a color HTML5
date A control for entering a date (year, month, and day, with no time). HTML5
datetime A control for entering a date and time (hour, minute, second, and fraction of a second) based on UTC time zone. HTML5
datetime-local A control for entering a date and time, with no time zone. HTML5
email A field for editing an e-mail address HTML5
file A control that lets the user select a file  
hidden A control that is not displayed, but whose value is submitted to the server.  
image A graphical submit button  
month A control for entering a month and year, with no time zone. HTML5
number A control for entering a floating point number. HTML5
password A single-line text field whose value is obscured  
radio A radio button  
range A control for entering a number whose exact value is not important HTML5
reset A button that resets the contents of the form to default values.  
search A single-line text field for entering search strings; line-breaks are automatically removed from the input value. HTML5
submit A button that submits the form.  
tel A control for entering a telephone number; line-breaks are automatically removed from the input value, but no other syntax is enforced HTML5
text A single-line text field; line-breaks are automatically removed from the input value.  
time A control for entering a time value with no time zone. HTML5
url A field for editing a URL HTML5
week A control for entering a date consisting of a week-year number and a week number with no time zone. HTML5
type - <input> - HTML | MDN

disabled

Firefoxでは、この属性への設定がページ再読み込み後も維持されます。

Firefox のデフォルト動作は他のブラウザと異なり、ページを再読み込みしても <input> を動的に無効化した状態を維持します。この機能は autocomplete 属性で制御できます。

属性 - input 要素 - HTML | MDN

メソッド

メソッド 説明
click 要素をクリックする※1
blur 要素からフォーカスを外す
focus 要素にフォーカスを移す
select 要素のテキストを選択し、フォーカスを移す
※1 type='file'のとき、セキュリティ上の理由によりクリックは制約を受けます。
Methods - HTMLInputElement - Web API Interfaces | MDN

イベント

イベントハンドラ イベントの発生状況
onchange テキスト入力要素では、ユーザーがテキストを変更しフォーカスを他へ移したとき
トグルボタン要素では、ユーザーがトグルを切り替えたとき
※IE9より前では、切り替え後フォーカスが他へ移動したとき
onclick ユーザーがマウスやキーボードで、ボタンをアクティブにしたとき
onblur ユーザーが要素からフォーカスを外したとき
onfocus ユーザーが要素にフォーカスを与えたとき
oninput input要素の値が変化したとき
IE9より前では非対応のため、同時にonchangeも登録する
Properties - GlobalEventHandlers - Web API Interfaces | MDN

プログラムから変更したときは、これらのイベントは発生しません。

JavaScriptのドキュメントから検索