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

Instructional text color being reset when form is cleared

Explorer ,
Feb 18, 2021 Feb 18, 2021

Copy link to clipboard

Copied

Okay, I've set up a form with several fields containing instructional text that have the On Focus/On Blur pair of actions with Javascript that sets the text to a teal color that I defined when it displays the instructions and black text when it displays the user input. This is for a tool that is intended to be used over and over, so there is a form reset button to clear user-input, but when I hit that, all of the instructional text is now black instead of the teal. If I click through each field without inputting, it reverts to the teal on blur, but ideally I would like it to remain teal when reset.

 

I have changed the default color in the appearance properties from the auto black to the teal and it doesn't make an impact upon reset. Is there a way around this? (If the answer is "no," that's fine, the client doesn't know I successfully go the on blur to work in the first place and would accept black text all the time, but it looks really slick and I'd love to rescue this functionality if possible!)

 

Thank you!

TOPICS
JavaScript , PDF forms

Views

795

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 , Feb 18, 2021 Feb 18, 2021

Try deleting 'On Blur', 'On Focus' and document level script you have and use just 'Custom format script' like this:

if (!event.value) {

event.value = "Provide context for why they’re getting this survey in a way that gives them a reason and makes them feel uniquely qualified to respond";

event.target.display = display.noPrint;
event.target.textColor = ["RGB", 0.016, 0.584, 0.694];
} else {
event.target.display = display.visible;

event.target.textColor = color.black;

}

It will revert back to teal when yo

...

Votes

Translate

Translate
Explorer ,
Feb 18, 2021 Feb 18, 2021

Copy link to clipboard

Copied

Sorry, cannot figure out how to edit original post, but upon further review, the color in the appearance properties is actually being set to black after I input text and tab out of the field. That...is surprising, but establishes that changing the appearance property color isn't going to effectively keep it the teal after a reset anyway, unless that particular change (of different fields' text color) can be coded into the reset button?

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
Enthusiast ,
Feb 18, 2021 Feb 18, 2021

Copy link to clipboard

Copied

Can you share code you use or your file?

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 ,
Feb 18, 2021 Feb 18, 2021

Copy link to clipboard

Copied

For the custom format to display the information text:

// Custom Format script for text field

if (!event.value) {

event.value = "Provide context for why they’re getting this survey in a way that gives them a reason and makes them feel uniquely qualified to respond";

event.target.display = display.noPrint;

} else {

event.target.display = display.visible;

}

 

The on focus Javascript action is:

// On Focus script:
if (event.target.value==event.target.defaultValue) {
    event.target.value = "";
    event.target.textColor = color.black;
}

 

The on blur Javascript action is:

// On Blur script:
if (event.target.value=="") {
    event.target.value = event.target.defaultValue;
color.teal= ["RGB", 0.016, 0.584, 0.694];
    event.target.textColor = color.teal;
}

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 ,
Feb 18, 2021 Feb 18, 2021

Copy link to clipboard

Copied

The teal is defined in the first field's on blur script only, that line doesn't repeat in all of the on blur for the remaining instruction text fields, but I also added it as document level javascript in case that was contributing to the black text reset.

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 ,
Feb 18, 2021 Feb 18, 2021

Copy link to clipboard

Copied

Try deleting 'On Blur', 'On Focus' and document level script you have and use just 'Custom format script' like this:

if (!event.value) {

event.value = "Provide context for why they’re getting this survey in a way that gives them a reason and makes them feel uniquely qualified to respond";

event.target.display = display.noPrint;
event.target.textColor = ["RGB", 0.016, 0.584, 0.694];
} else {
event.target.display = display.visible;

event.target.textColor = color.black;

}

It will revert back to teal when you reset form.

Just one thing though, when you start writing, text will be in teal but when you click outside field text will turn black.

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 ,
Feb 18, 2021 Feb 18, 2021

Copy link to clipboard

Copied

Thanks, Nesa, I will give this a shot tomorrow morning and report back if I am still struggling with it!

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 ,
Feb 19, 2021 Feb 19, 2021

Copy link to clipboard

Copied

LATEST

Thank you, Nesa, that worked perfectly! I'll update all the fields and submit to the client to see if she cares one way or the other about typing in teal (it's slightly confusing from a usability standpoint, but I think she's going to prefer the differentiation). I appreciate your help!

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