Skip to main content
WolfShade
Legend
May 14, 2020
Question

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

  • May 14, 2020
  • 2 replies
  • 1076 views

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,

 

^ _ ^

This topic has been closed for replies.

2 replies

WolfShade
WolfShadeAuthor
Legend
May 15, 2020

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,

 

^ _ ^

Nancy OShea
Community Expert
Community Expert
May 14, 2020

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