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

Sentence Case?

sonerndes
Level 2
Level 2

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.

0 Replies
sonerndes
Level 2
Level 2

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

dcidev
Level 8
Level 8

Try this:

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

Kyle

sonerndes
Level 2
Level 2

Thank you but that didn’t work.

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

dcidev
Level 8
Level 8

Oh ya. Put this first then:

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

Kyle

sonerndes
Level 2
Level 2

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?

dcidev
Level 8
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

sonerndes
Level 2
Level 2

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?

dcidev
Level 8
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

sonerndes
Level 2
Level 2

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