Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

SOLVED

Restrict Page name to be lower-case

Avatar

Level 2

How can we restrict the page name to be lower case when creating a new page? If the name is left empty, it takes the the value entered into the title field. We want to use the same value but convert it to a lowercase. 

 

Thanks

Ani

 

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Hi,

 

I have achieved this by using validator , below code will convert caps into lower case and also converts _ into -. You can add additional logic as per your need

 

$(window).adaptTo("foundation-registry").register("foundation.validation.validator", {

  selector: ".pageName",

  validate: function(el) {

    $(".pageName").val($(".pageName").val().replace(/_/g, '-').replace(/-{2,}/g, '-').toLowerCase());

  }

});

View solution in original post

2 Replies

Avatar

Correct answer by
Community Advisor

Hi,

 

I have achieved this by using validator , below code will convert caps into lower case and also converts _ into -. You can add additional logic as per your need

 

$(window).adaptTo("foundation-registry").register("foundation.validation.validator", {

  selector: ".pageName",

  validate: function(el) {

    $(".pageName").val($(".pageName").val().replace(/_/g, '-').replace(/-{2,}/g, '-').toLowerCase());

  }

});

Avatar

Community Advisor

Hi,

AEM does it for you. Can you please let me know the following :

1. Which version of AEM are you using?

2. Checking for AEM page title? can you share example page title?