textbox focus out
Solution 1
I have tried all the answers and not worked in all the browsers. And I combined all together in to it.
TextBox.readonly = true;
OnFocus:
var curText = TextBox.value;
TextBox.value = "";
TextBox.value = curText;
TextBox.blur();
TextBox_Parent.focus()
And its working fine in all the browsers
Solution 2
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).
Solution 3
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.
Solution 4
Where is the point in that? JS would be (didn't test it):
$('#textbox').focusin(function() {
$(this).focusout();
});
Santhosh
I'm so eager to learn new stuff's and to work in cutting edge technologies. I have around 4 years of experience in various technologies like Java, Asp.Net MVC, Javascript frameworks.
Updated on October 07, 2020Comments
-
Santhosh over 3 years
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()
-
E. van der Spoel almost 6 yearsThis code includes JQuery. The question is about vanilla javascript.