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

270
Vistas
How to detect that the parseFloat() stopped on "other" character?

For getting the float value from the webform (client-side event), I do use the code like:

var price = parseFloat(s.GetText());
if (!isNaN(price)) {
    // calculate the related values
}

It works fine when the user enters a number (correctly). The isNaN() works detects fine also the situation when the user types a string instead of a number (that is, when the first character does not belong to a number).

When the user types the value like 5 x, the 5 is converted correctly because the parser stops on x, and ignores the existence of the x. So, the unwanted string after the number is not detected. However, storing the field content 5 x into the database fails -- because the other code of the web page parses the value differently, and it requires it to be a number and nothing more.

How would you implement the check?

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