Restrict Page name to be lower-case | Community
Skip to main content
Level 2
April 29, 2022
Solved

Restrict Page name to be lower-case

  • April 29, 2022
  • 2 replies
  • 1491 views

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

 

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by Ravi_Pampana

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());

  }

});

2 replies

Ravi_Pampana
Community Advisor
Ravi_PampanaCommunity AdvisorAccepted solution
Community Advisor
April 29, 2022

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());

  }

});

arunpatidar
Community Advisor
Community Advisor
April 30, 2022

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?

Arun Patidar
manuel_óscars89
Level 2
June 6, 2023

Hi,

 

sorry to resurrect this answer but I am doing it for the sake of other people facing this problem.

 

The official documentation for AEM 6.5 and AEMaaCS states that:

"When creating a new page, AEM will validate the page name according to the conventions imposed by AEM and the JCR.

The minimum allowed characters are:

 ‘a’ through to ‘z’
 ‘A’ through to ‘Z’
 ‘0’ through to ‘9’
 _ (underscore)
 - (hyphen/minus)"

 

So uppercase letters are allowed in the "Name" field.

 

Source for AEM 6.5 (Last Updated: April 18, 2023): https://experienceleague.adobe.com/docs/experience-manager-65/authoring/authoring/managing-pages.html?lang=en#page-naming-conventions

 

Source for AEMaaCS (Last Updated: September 22, 2022): https://experienceleague.adobe.com/docs/experience-manager-cloud-service/content/sites/authoring/fundamentals/organizing-pages.html?lang=en#page-name-restrictions-and-best-practices

 

@ravi_pampana's answer is correct because you will have to create some custom code to change upper case letters to lower case if you do not want them like that.

 

Kind regards.