Setting regular expression to validate URL format in Adobe CQ5 | AEM Community Blog Seeding

Avatar

Avatar

kautuk_sahni

Community Manager

Total Posts

6.0K

Likes

1.1K

Correct Reply

1.1K

Avatar

kautuk_sahni

Community Manager

Total Posts

6.0K

Likes

1.1K

Correct Reply

1.1K
kautuk_sahni
Community Manager

26-05-2020

BlogImage.jpg

Setting regular expression to validate URL format in Adobe CQ5 by howtoaem Blog

Abstract

I want to validate a URL inside a textfield using Adobe CQ5, so I set up the properties regex and regexText as usual, but for some reason is not working:


So when I type inside the component I can see an error message at the console:

Uncaught TypeError: this.regex.test is not a function
To be more accurate the error comes from this line:

if (this.regex && !this.regex.test(value)) {
I tried several regular expressions and none of them worked. I guess the problem is the regular expression itself, because in the other hand I have this other regex to evaluate email address, and it works perfectly fine:

/^[A-za-z0-9]+[\\._]*[A-za-z0-9]*@[A-za-z.-]+[\\.]+[A-Za-z]{2,4}$/
Any suggestions? Thanks in advance

Read Full Blog

Setting regular expression to validate URL format in Adobe CQ5

Q&A

Please use this thread to ask the related questions.

AEM AEMEBlogSeeding Experience Manager