Expand my Community achievements bar.

Sentence Case?

Avatar

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.

10 Replies

Avatar

Level 2

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

Level 2

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

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?

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

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?

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

Level 2

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

page footer
Change Username