Expand my Community achievements bar.

SOLVED

[PathField] What is difference between maskRe, regex, stripCharsRe config option of Class CQ.form.PathField.

Avatar

Administrator

Hi Community

I was going through the documentation Link:- https://docs.adobe.com/docs/en/cq/5-6/widgets-api/index.html?class=CQ.form.PathField .

I am bit confuse between maskRe, regex, stripCharsRe config options. If some body could explain me  these three with an example.

Thanks and Regards

Kautuk Sahni



Kautuk Sahni
1 Accepted Solution

Avatar

Correct answer by
Employee

maskRe is supposed to prevent certain characters from being entered into a field.  I tried to get it working on a textfield but was unsuccessful due to a JS error.  Basically you're supposed to be able to add a the property such as maskRe=/[a-zA-Z\s]*/ and this example will prevent any char other than letters and spaces from being entered into the field.

According to the docs (https://docs.adobe.com/docs/en/cq/5-6-1/widgets-api/index.html?class=CQ.form.PathField):

  • maskRe : filter out keystrokes before any validation occurs

View solution in original post

4 Replies

Avatar

Level 10

Hi Kautuk

regex: Take a look at my latest article published 1 hour back http://adobeaemclub.com/simple-way-to-restrict-image-type-in-pathfield-xtype/

stripCharsRe: If you want to remove some text from the value selected in Path field. To the above article if you add property with name stripCharsRe with  value /content/  . After this if you select /content/dam/geometrixx/banners/banner-mono.png, in path field you will see only dam/geometrixx/banners/banner-mono.png as you are instructing aem to strip /content/

for maskRe : I will get back to you with better example

Thanks

Avatar

Correct answer by
Employee

maskRe is supposed to prevent certain characters from being entered into a field.  I tried to get it working on a textfield but was unsuccessful due to a JS error.  Basically you're supposed to be able to add a the property such as maskRe=/[a-zA-Z\s]*/ and this example will prevent any char other than letters and spaces from being entered into the field.

According to the docs (https://docs.adobe.com/docs/en/cq/5-6-1/widgets-api/index.html?class=CQ.form.PathField):

  • maskRe : filter out keystrokes before any validation occurs

Avatar

Administrator

Hi Praveen, Graham

This really help. Thank you for the detail answer. 

Thanks and Regards

Kautuk Sahni



Kautuk Sahni

Avatar

Level 1

I managed to get around the error by setting maskRe as a function, like the following:

maskRe="function(){return eval('/\\\\d/')}()"

It looks like in CQ.utils.Util.formatData only the 'regex' field is evaluated, not maskRe.

Hopefully that helps someone!