Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

174
Vistas
How to check if a value is not a number in javascript?

I am trying to validate user input to see if they enter a number and show an error if they enter anything that's not a number.

here is the html element

<input type="text" id="user_input">

here is my javascript

let user_input = Number(document.querySelector("#user_input").value);

if (user_input == NaN) {
    console.log("its not a number");
} else {
    console.log("its a number");
}

Here, when I enter a string, it still says "its a number" on the console. Why is this happening?

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda