Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.

Sentence Case?

Avatar

Former Community Member

I have a field for comments.  The users enter paragraphs about thier experiences.  I have several users who always type in all caps and it becomes very difficult to read.  Is there a script to convert uppercase to sentence case?  I'm not even sure if sentence case is the correct terminology.

10 Replies

Avatar

Former Community Member

This works for one sentence. But once the next sentence begins how do I script it to recognize a new sentence begins?

Avatar

Level 8

Try this:

this.rawValue = this.rawValue.replace(/(^|\.\s*)([a-z])/g, function (_, first, initial) {return first+initial.toUpperCase();});

Kyle

Avatar

Former Community Member

Thank you but that didn’t work.

I am trying to convert sentences that were typed in all caps to sentence case.

Avatar

Level 8

Oh ya. Put this first then:

this.rawValue=this.rawValue.toLowerCase();

Kyle

Avatar

Former Community Member

Thanks, that works great. But one other thing. There are words now that become lower case, such as names that need to be capitalized.

Is there a way for me to be able to edit the words?

Avatar

Level 8

The only way to automate the task is to have a source of proper names you can reference. Besides that is to manually edit the names yourself.

Kyle

Avatar

Former Community Member

Thank you for your reply.

It would not let me manually edit the names after the script changed it to lower case.

Do you have any other suggestions?

Avatar

Level 8

You could try putting in a condition that only runs the code when you hold down the Ctrl key:

if (xfa.event.modifier){

.

.

.

}

Kyle

Avatar

Former Community Member

Do I put this before the code to change the font or afterward?