Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

227
Visualizações
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 Respostas
Responde à pergunta

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 Relatório

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda