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

Extract specific text (or number) value from field

Engaged ,
Apr 22, 2021 Apr 22, 2021

Copy link to clipboard

Copied

Hi all,

 

Am wondering if it is possible (with JavaScript?) to extract specific text or text/numeric value from a separate field that a user has entered a value? e.g. - If "Text1" has a user entered value of "joe bloggs 2021", is it possible in "Text2" field, to extract only the "2021" value from the user entered text string, and populate that value (i.e. "2021") in to the "Text1" field??.

 

Thanks..... 

TOPICS
PDF forms

Views

1.5K

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

Community Expert , Apr 22, 2021 Apr 22, 2021

Use this as 'validation' script of 'Text1' field:

this.getField("Text2").value = event.value.split(" ").pop();

Votes

Translate

Translate
Community Expert ,
Apr 22, 2021 Apr 22, 2021

Copy link to clipboard

Copied

Use this as 'validation' script of 'Text1' field:

this.getField("Text2").value = event.value.split(" ").pop();

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
Engaged ,
Apr 22, 2021 Apr 22, 2021

Copy link to clipboard

Copied

Thanks Nesa! 😉

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 ,
Apr 22, 2021 Apr 22, 2021

Copy link to clipboard

Copied

LATEST

The code above will work, but will allow the user to overwrite that value (unless Text2 is set to read-only).

If you don't want that then you should use a calculation script for Text2, instead.

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