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

77
Visualizações
Ignoring non required field

I am trying to get my code to ignore a specific field that doesn't require text at all, but if it has anything other than numeric values in it, it will give me an error. Instead, it gives me the errors when Nothing is entered. The code I have in question is a regex function for checking numeric value, my validation function calls to the numeric regex function, and if

input.classList.contains "numeric".

If the regex is not validated, it will give an error.

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Your regex /^([0-9])+$/ in checkNumeric() expects at least one digit because of the +. Try /^([0-9])*$/. This accepts empty string as well, because * matches 0 til infinity digits.

EDIT: I created a program showing the regex in action.

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