• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

JavaScript RegEx validation: how to highlight what didn't match

LEGEND ,
May 14, 2020 May 14, 2020

Copy link to clipboard

Copied

Hello, all,

 

I'm in the process of writing something to add to an existing project.  The ability for a user to include up to five email addresses to CC an attachment to said addresses.  I've got the validation working as I want it.  Now, just for giggles, I'd like to have the ability to highlight what part of a malformed email address didn't match the email mask.

 

I've seen examples where, in a string search, the entered word would be highlighted in other words.  For example:  A list of words like, "car", "escape", "abracadabra", and someone enters "ca", then it would appear like:

car

escape

abracadabra

 

But I wonder if RegEx can be used to highlight what failed validation of an email address?

 

V/r,

 

^ _ ^

TOPICS
Bootstrap , Browser , Code , Download install and licensing , Error , Extensions , How to , Import and export , Interface , Other , Performance , Preview , Product issue , Publish , Server side applications

Views

1.0K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 14, 2020 May 14, 2020

Copy link to clipboard

Copied

Failed e-mail syntax patterns are mostly caused by typos.  For example, a missing @ sign or 2 dots before the TLD.  In some cases, an unrecognized TLD (.com.tv).   I don't know how you would express that in a meaningful way with RegEx, sorry.

 

Nancy O'Shea— Product User, Community Expert & Moderator

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
May 15, 2020 May 15, 2020

Copy link to clipboard

Copied

LATEST

Hi, Nancy,

 

I'm just assuming that it can be done.. mostly because 99% of RegEx is unknown to me, and I know a lot more can be done with it than I could ever dream.  I will try to reverse-engineer the string search examples and see if I can somehow get a highlight on what failed, but I'm not very hopeful.  🙂

 

V/r,

 

^ _ ^

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines