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

261
Views
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
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!