Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

textbox focus out

I need to focus out from the textbox when it focus in.

I try to set focus for outer div and its working fine in IE but not in mozilla.

How do I do this?

This is my current code:

<div id="outer"> <input type = "textbox" /></div> Onfocus: document.getElementById("outer").focus()
like image 493
Santhosh Avatar asked Feb 03 '10 12:02

Santhosh


2 Answers

I wonder what's the purpose of using a textbox in this case if the user can never write anything inside. Just add a disabled="disabled" attribute or readonly="readonly" (in case you want to post the value).

like image 122
Darin Dimitrov Avatar answered Oct 17 '22 10:10

Darin Dimitrov


In HTML:

<input type="text" onfocus="this.blur();" />

In JS:

document.getElementById("input1").onfocus = function () { this.blur(); }

Some elements cannot accept focus without being editable.

like image 33
Andy E Avatar answered Oct 17 '22 11:10

Andy E