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

91
Visualizações
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 Respostas
Responde à pergunta

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 Relatório

0

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

/^0/
about 4 years ago · Juan Pablo Isaza Relatório
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