• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Convert text to lowercase

Explorer ,
Jun 14, 2024 Jun 14, 2024

Copy link to clipboard

Copied

I have two fields - Text1 and Text2.  Text1 is set to capitalize whatever is entered into it with the following custom validation script:  event.value = event.value.toUpperCase();

 

Text2 is set to copy into it whatever is entered into Text1 with the following custom calculation script:  getField("Text2").value = getField("Text1").valueAsString;

 

I am looking for custom validation script that will convert Text2 to capitalize only the first letter of each word that is entered in Text1.  For example, if "OHIO" is entered into Text1, I would like Text2 to show "Ohio".  If "NEW JERSEY" is entered into Text1, I would like Text2 to show "New Jersey".

 

Thanks.

TOPICS
JavaScript , PDF forms

Views

96

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Enthusiast , Jun 14, 2024 Jun 14, 2024

Use the following custom validation script:

 

function toTitleCase(str) 
{
return str.replace(
/\w\S*/g,
function(txt) 
{
return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();
}
);
}

event.value=toTitleCase(event.value);

Votes

Translate

Translate
Enthusiast ,
Jun 14, 2024 Jun 14, 2024

Copy link to clipboard

Copied

Use the following custom validation script:

 

function toTitleCase(str) 
{
return str.replace(
/\w\S*/g,
function(txt) 
{
return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();
}
);
}

event.value=toTitleCase(event.value);

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jun 14, 2024 Jun 14, 2024

Copy link to clipboard

Copied

LATEST

Works great.  Thanks!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines