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

185
Views
Can anyone tell me why this function throws up an error when called

   <html>
    
    <script>
    
    
    function isNumber(value) {
        return typeof (value) != "boolean" && !isNaN(value) && value.length > 0;
    }
    
    function minMaxTempDecimal(value, min, max, unit) {
        console.log("D function called");
        if (value.length == 0 || value == "-") return value;
        if (!isNumber(value)) return value.substring(0, value.length - 1);
    
        value = parseFloat(value);
        if (value) < min)
            return min;
        else if (value > max)
            return max;
        return value.toFixed(1);
    
    }
    </script>
    
    <tr>
            <th>Differntial</th>
            <th><input id="differentail" type="text" name="differentail" value="1" onkeyup="this.value = minMaxTempDecimal(this.value, 0.1, 5, 0)"   /></th>
          </tr>
          
    </html>

The function does the following

  • limits the values from 0.1 to 5
  • only decimal places to one point ie step size of 0.1
  • doesn't allow characters
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Read the error. You have an extra ) in your JS code.

The following works:

   <html>
    
    <script>
    
    
    function isNumber(value) {
        return typeof (value) != "boolean" && !isNaN(value) && value.length > 0;
    }
    
    function minMaxTempDecimal(value, min, max, unit) {
        console.log("D function called");
        if (value.length == 0 || value == "-") return value;
        if (!isNumber(value)) return value.substring(0, value.length - 1);
    
        value = parseFloat(value);
        if (value < min)
            return min;
        else if (value > max)
            return max;
        return value.toFixed(1);
    
    }
    </script>
    
    <tr>
            <th>Differntial</th>
            <th><input id="differentail" type="text" name="differentail" value="1" onkeyup="this.value = minMaxTempDecimal(this.value, 0.1, 5, 0)"   /></th>
          </tr>
          
    </html>

about 4 years ago · Juan Pablo Isaza Report
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!