Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

241
Views
Get the value of input when the cursor is out in javascript?

I have a input :

<a-form-item label="user" :colon="false">
    <a-input placeholder="user" name="user" @keyup.enter="checkUser"/>
</a-form-item>

In methods:

checkUser() {
   console.log('ok');
},

In methods : checkUser when i enter then i get the input value. But now I don't want to do that, I want when I finish entering the input value, move the cursor outside and methods : checkUser will get the value of that input. Thank you

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

Make use of blur event listener.

<a-input placeholder="user" name="user" @blur="checkUser"/>

Sample Fiddle

new Vue({
  el: '#app',
  data: {},
  methods: {
    checkUser: function(e) {
      console.log("Blur event triggered", e.target.value)
    }
  },
})
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.1.4/vue.js"></script>
<div id="app">
  <input type="text" @blur="checkUser">
</div>

about 4 years ago · Juan Pablo Isaza Report

0

If you want the method to get triggered while moving out the cursor then you can use @mouseleave event. OR If you want to trigger the method when the input loses focus then you could try using @blur event

new Vue({
  el: '#app',
  methods: {
    checkUser(e) {
      if(e.target.value !== '') { // To check if the input is not empty
        console.log("event triggered", e.target.value)
      }
      return;
    }
  },
})
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.1.4/vue.js"></script>
<div id="app">
  <input type="text" @mouseleave="checkUser">
  <!-- OR -->
  <!--<input type="text" @blur="checkUser"> -->
</div>

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!