HTML onblur イベント属性

❮ HTML イベント属性

ユーザがそこを離れたときに入力フィールドを検証します:

<input type="text" name="fname" id="fname" onblur="myFunction()">
Try it Yourself ❯

他の "Try it Yourself" の例が下にあります。


定義と用法

onblur 属性は、要素がフォーカスを失った瞬間に発火します。

Onblur は、ほとんどの場合、(例えば、ユーザがフォームフィールドを離れる時に)フォームのコード検証に使用されます。

チップ: onblur attribute is the opposite of the onfocus attribute.


ブラウザ・サポート

イベント属性
onblur Yes Yes Yes Yes Yes

HTML 4.01 と HTML5 の相違点

なし。


構文

<element onblur="script">

属性値

説明
script script は onblur で実行される

技術的詳細

サポートする HTML タグ: 次の要素を除くすべての HTML 要素: <base>, <bdo>, <br>, <head>, <html>, <iframe>, <meta>, <param>, <script>, <style>, and <title>

Examples

その他の例

"onblur" と一緒に "onfocus" 属性を使用します:/p>

<input type="text" onfocus="focusFunction()" onblur="blurFunction()">
Try it Yourself ❯

関連ページ

HTML DOM リファレンス:onblur イベント


HTML Event Attributes HTML イベント属性