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

80
Vistas
Regular expression to determine if phone number starts with a zero

How would I go about ensuring that numbers entered into a field starts with a 0? My initial question was suggesting that the company wants to force users to input 0 first, but I think an elegant solution would work better.

    function creationValidationNumber(dataValues, setErrors) {
     let testData:any = {};

     if ("numberPrime" in dataValues) testData.numberPrime = /^[a-zA-Z][0-9a-zA-Z 
     .,'-]*$/g.test(dataValues.numberPrime) ? "" : "Numbers must start with a 0";

     setErrors({ ...testData });

     return Object.values(testData).every((x) => x === "");
    }

I just don't know how to get the regular expression to test and throw an error if it doesn't start with 0

If anyone could please guide me on the right path.

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

0

You don't need regex for this. Just check if the first character is "0":

dataValues.numberPrime[0] == "0"
about 4 years ago · Juan Pablo Isaza Denunciar

0

I don't know why you have a more complicated regex, all you need is:

/^0/
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