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

275
Visualizações
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 à 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