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

richValue in Validate

Community Beginner ,
Jun 29, 2023 Jun 29, 2023

Hi,
setting the value does not work in the "Validate" event. I have the field set correctly to richText, but even when I use event.richValue or event.target.richValue, the text still does not appear in the field. On Mouse events event.target.richValue works normally.
Here is my code:

// inputed in Validate
span1 = {text: "Hi, There!"};
event.richValue = [span1];
TOPICS
Acrobat SDK and JavaScript
701
Translate
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 ,
Jun 29, 2023 Jun 29, 2023

To apply a value you should use the Calculate event.

Translate
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 Beginner ,
Jun 29, 2023 Jun 29, 2023

I don't want to use Calculate, I want Validate.

Specifically, it doesn't work to insert a value if the field is empty.

if(event.richValue.length===0){
	span1 = {text: "Hi, There!"};
	event.richValue = [span1]
};

Here is my code:

Translate
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 ,
Jun 29, 2023 Jun 29, 2023

What are you trying to achieve here, exactly?

Translate
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 ,
Jun 29, 2023 Jun 29, 2023
LATEST

If you want to set the field's value to this text when it's empty just change the first line to:

if (event.value.length==0) {

Translate
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