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

153
Views
Regex for Invalid emails

I have to create some validation for emails using regex.

I wrote these parts from the validation:

  const regex = {
  whitespace: /^(?!\s+$)/g,
  emailMultipleSeparatedBySemicolon:/^(\s?[^\s,]+@[^\s,]+\.[^\s,]+\s?;)*(\s?[^\s,]+@[^\s,]+\.[^\s,]+)$/g,
};

and I'm using it this way in the code:

 sendTo: Yup.string()
        .max(255, this.props.t("createEmail.error.errorTooLong255"))
        .matches(
          regex.emailMultipleSeparatedBySemicolon,
          this.props.t("createEmail.error.emailMultipleSeparatedBySemicolon")
        )
        .matches(
          regex.whitespace,
          this.props.t("createEmail.error.errorNoWhitespace")
        )
        .required(this.props.t("createEmail.error.required")),

However when I add more than one recipient like this: hNw6B@90.com;test , I don't get the error for invalid email, although the second one test (after the semicolon) is not valid. If I add it this way: hNw6B@90.com; test (with space between the semicolon and test) - it is marked as invalid.

I will be very grateful if you can help me out!

about 4 years ago · Juan Pablo Isaza
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!