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

237
Vistas
I have made a simple calculator but How I can prevent users from entering dot several times in one number ? so far i can only prevent double dots

if

(previousNum == "." && currentNum == ".") { screen.value = screen.value.substring(0, numchar - 1);

about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

You are using javascript. you can split it on "." then count the length of the array which should be 2 or less.

var x = '12.34.56';
var arr = x.split(".")
var number_of_dots = arr.length - 1
console.log(number_of_dots)

about 4 years ago · Juan Pablo Isaza Denunciar

0

I think you can check if the number is Integer or float with this sample function

function isFloat(n){
    return Number(n) === n && n % 1 !== 0;
}
function isInt(n) {
   return n % 1 === 0;
}

and write catch, so if had error the entered number is not valid for you calculator

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