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

Changing Characters to Lowercase

New Here ,
Sep 29, 2023 Sep 29, 2023

Copy link to clipboard

Copied

I need help with a script to change a specific character to lowercase if it was typed in uppercase in a field. Example: 24X12X6 I need just the X's to be changed to lowercase when a button is pressed, only if a number is before and after it. Thanks!

TOPICS
Acrobat SDK and JavaScript

Views

153

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
Community Expert ,
Sep 29, 2023 Sep 29, 2023

Copy link to clipboard

Copied

As the field's custom Validation script enter this:

event.value = event.value.toLowerCase();

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
Community Expert ,
Sep 29, 2023 Sep 29, 2023

Copy link to clipboard

Copied

Sorry, I might have read it too quickly... Do you expect there to be other (non-numeric) characters in the field?

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
New Here ,
Sep 29, 2023 Sep 29, 2023

Copy link to clipboard

Copied

I actually copied and pasted my question in to ChatGPT and it gave me almost exactly what I needed.

 

// Get the input field value
var inputField = this.getField("Description");
var inputValue = inputField.value;

// Use a regular expression to find and replace 'X' with 'x' when surrounded by numbers
var replacedValue = inputValue.replace(/(\d)X(\d)/g, '$1x$2');

// Update the input field with the modified value
inputField.value = replacedValue;

 

Thank you though!

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
Community Expert ,
Sep 29, 2023 Sep 29, 2023

Copy link to clipboard

Copied

Where are you planning on using this script? Will it be on the field where the text to be converted will be placed?

If so you'll need to make some changes. The script you have will only work from outside the field.

 

 

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

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
New Here ,
Sep 29, 2023 Sep 29, 2023

Copy link to clipboard

Copied

LATEST

It's triggered from a button outside of the field that also triggers a number of other things. It works.

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