Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

217
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!