Questions tagged [onfocusout]

The onfocusout event occurs when an element is about to lose focus.The onfocusout event is similar to the onblur event. The main difference is that the onblur event does not bubble. Therefore, if you want to find out whether an element or its child loses focus, you should use the onfocusout event.

Definition and Usage

  • The onfocusout event occurs when an element is about to lose focus.
  • The onfocusout event is similar to the onblur event. The main difference is that the onblur event does not bubble. Therefore, if you want to find out whether an element or its child loses focus, you should use the onfocusout event.
  • Although Firefox does not support the onfocusout event, you can find out whether a child of an element loses focus or not, by using a capturing listener for the onblur event (using the optional useCapture parameter of the addEventListener() method).
  • The onfocusout event is the opposite of the onfocusin event.
  • The onfocusout event may not work as expected in Chrome, Safari and Opera 15+ using the JavaScript HTML DOM syntax. However, it should work as an HTML attribute and by using the addEventListener() method.

Example

Execute a JavaScript when an input field is about to lose focus:

<input type="text" onfocusout="myFunction()">

Syntax

  • In HTML :

    <element onfocusout="myScript">
    
  • In JavaScript :

    object.onfocusout = function(){myScript};
    
  • In JavaScript, using the addEventListener() method :

    object.addEventListener("focusout", myScript);
    

References : w3schools

14 questions
4
votes
1 answer

jquery : focusout of non-required textarea prevent trigger click event of save button

I have a form witha textarea as non-required.When I edit the value inside textarea and click save or cancel or delete immediately it doesn't trigger 1st time but triggers in second click. Like below image And I have my jquery-validate onfocusout…
1
vote
1 answer

How to call function after change input

Using Angular 1.6 I´m trying to call some function like $scope.myFunction after change inputs My code look like this
1
vote
1 answer

onfocusout preventing dropdown menu item to click in Blazor

Loving Blazor. I want a dropdown menu to close when I click away. I've added onfocusout to the surrounding div to set the showDropdown toggle to false, and this makes the menu close. However, this then disables the menu items onclick events (e.g. to…
HWTurk
  • 41
  • 4
1
vote
1 answer

onfocusout runs before navigation trigger

I am experiencing issues triggering a dropdown's navigation when working with onblur or onfocusout in blazor. The razor page's HTML:
1
vote
0 answers

How do I provide an exception for an onfocusout event when clicking on a specific element?

I have an HTML form element that I want to use to create a dynamic drop-down list of options with auto-suggestions as people type.
Joe
  • 11
  • 2
1
vote
1 answer

JavaScript catch onfocus event

I have some inputs and a button. I want to implement function which allows to delete one of recently focused/focused out input. I set onfocusout function which sets a click listener on button. If I focus on first input then focus out from it and…
1
vote
1 answer

How do I pass the `number_entered_by_user` in a Javascript through `onfocusout(number_entered_by_user)` event

How do I pass the number_entered_by_user in a Javascript through onfocusout(number_entered_by_user) event? Pretty much new with Javascript and DOM manipulation. Have searched on this site but unable to find an relevant answer. I have a tag…
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
0
votes
1 answer

How to call a method every single time the field loses focus in vue.js

This looks easy, but somehow wouldn't work. I have a text-field with an @blur listener to make a call to the server to check if the username typed exist in the database. Once the field loses focus, the method is called; if the username exists…
banky
  • 838
  • 2
  • 13
  • 26
0
votes
1 answer

chrome javascript add onfocus event doesn't fire

A couple of months ago, only in Chrome (my version Version 103.0.5060.114 (Official Build) (x86_64) OSX 12.4), onFocus events added using JavaScript do not fire. They fire in iOS Chrome, other browsers and will fire in Chrome OSX when embedded in…
Jim Geldermann
  • 183
  • 3
  • 18
0
votes
1 answer

Focus, blur, focusin, focusout, don't work with D3 and SVG Elements? Is there an alternative?

I'm using the d3 library to create a widget within a SVG. Within the SVG I'm trying to do the following: There are small rectangles that are clickable. Once clickable, they should "enlarge" and show some input fields. When I click outside the…
Mark
  • 75
  • 1
  • 7
0
votes
2 answers

Validate form field after user leaves the field

I want to validate a form field after user has left the field. I wrote my html as below
Mr.X
  • 117
  • 8
0
votes
1 answer

Validation error: Attribute onfocusout not allowed on element input at this point

I want to make use of "onfocusout" at an input element. Unfortunately my validators return the following error message: "Attribute onfocusout not allowed on element input at this point." The html code looks like this:
FernSeher
  • 177
  • 1
  • 13
0
votes
2 answers

Why doesn't setting an input type="number" to type="text" in an mouseout event handler working?

Goal: I have an input element in which the user should enter a number between 1 and 999, optionally may use the (input type="number") up/down spinner, but when the mouse isn't over this element or the element doesn't have the focus, I want the input…
user2505564
-1
votes
2 answers

is there an alternative to onfocusout() function?

I have a function onfocusout() that runs another function selectEntite() inside an input like the following code :