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

225
Vistas
How do i prevent formik yup ( regex ) validation from disappearing

This is my regex

        const firstNameSpecialChars = /[^\/\\#+()$~%.":;*<>{}@]/;

This is my validation

     const validationSchema = Yup.object().shape({
    email: Yup.string()
      .email(ENTER_VALID_EMAIL_MESSAGE)
      .required(EMAIL_IS_REQUIRED_MESSAGE),
    firstname: Yup.string()
      .trim()
      .matches(
        firstNameSpecialChars,
        'These characters are not allowed in name fields',
      ),

I want an error to be shown when there is a regex match. This works, but there is a problem... As soon as i type after the hash symbol the error disappears but when there is a symbol the error shows up

enter image description here

This is how my error looks like when I type regex chars

enter image description here

which is not what i want if there is special char i want the error to be there till the user removes the special char


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

0

Found a solution :

I had to do this :

Regex

/^[^#+()$~%.":;*<>{}@\\/\\]+$/

This gives me the error when anyone of the stuff inside the [ ] matches

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