Copy link to clipboard
Copied
Hello All,
I am looking for a way to capitalize the first letter of each sentence within a textfield of a custom form in Acrobat. This can be done once the user finishes entering their entry. I do not want any other text changed except the first letter, of every sentence separated by a period and a space. Any help is appreciated. Thank you!
Copy link to clipboard
Copied
Use this as 'Validate' or On Blur script:
var text = event.value;
var sentences = text.split(". ");
for (var i=0; i<sentences.length; i++) {
sentences[i] = sentences[i].charAt(0).toUpperCase() + sentences[i].slice(1);}
var newText = sentences.join(". ");
event.value = newText;
Copy link to clipboard
Copied
Try this. It's much simpler.
event.value = event.value.replace(/\b[^\.]*/gm, ((a)=>a.replace(/\w/,(b=>b.toUpperCase()))));
Copy link to clipboard
Copied
Use this as 'Validate' or On Blur script:
var text = event.value;
var sentences = text.split(". ");
for (var i=0; i<sentences.length; i++) {
sentences[i] = sentences[i].charAt(0).toUpperCase() + sentences[i].slice(1);}
var newText = sentences.join(". ");
event.value = newText;
Copy link to clipboard
Copied
Thank you this worked!
Copy link to clipboard
Copied
Is it a multi-line field? Should happen if the user presses Enter without a period at the end of the sentence? Or if the sentence ends with a question mark, or an exclamation point?
Copy link to clipboard
Copied
Yes multi-line text box. Multiple senetences. Data is entered in paragraph form. Basically looks for when they click to the next field, the magic happens. There should not be any question marks or exclamation points in this field however we can include, if easy.
Copy link to clipboard
Copied
Then use the code provided above.
Copy link to clipboard
Copied
Try this. It's much simpler.
event.value = event.value.replace(/\b[^\.]*/gm, ((a)=>a.replace(/\w/,(b=>b.toUpperCase()))));
Copy link to clipboard
Copied
Thank you!! It also worked.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now