Menu Close

How to call a function as soon as the cursor moves from one text box to next in Vue.js?

Sometimes, we want to call a function as soon as the cursor moves from one text box to next in Vue.js.

In this article, we’ll look at how to call a function as soon as the cursor moves from one text box to next in Vue.js.

How to call a function as soon as the cursor moves from one text box to next in Vue.js?

To call a function as soon as the cursor moves from one text box to next in Vue.js, we can listen to the blur event.

For instance, we write

<template>
  <div id="app">
    <input @blur="handleBlur" placeholder="first name" />
    <input @blur="handleBlur" placeholder="last name" />
  </div>
</template>

to listen to the blur event and run the handleBlur method if the event is triggered with

@blur="handleBlur" 

Conclusion

To call a function as soon as the cursor moves from one text box to next in Vue.js, we can listen to the blur event.

Posted in vue