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

Changing Text Box Border Color to transparent once text is entered

Community Beginner ,
Jun 12, 2020 Jun 12, 2020

Copy link to clipboard

Copied

Hello,

 

I am going nuts here. I have a form which has a BUNCH of text fields in it. All of my other scripts are working except this one. I am aware that there is a mandatory field option in Adobe BUT I cannot seem to find any settings to turn off the red border once the field has had a value entered into it. The border color simply will not change from the default 'red' even when a vlaue has been entered.

 

So I thought a calc script might do the trick:

 

if (this.getField("LastName").value>="")
{
event.target.strokeColor = color.transparent;
}
else
{
if (this.getField("LastName").value="")
{
event.target.strokeColor = color.red;
}
}

 

The goal is seemingly simple here....

 

IF textbox has no entry border = Red

else 

No border as the textbox has a value in it now.

 

Any help is greatly appreciated.

 

 

On a side note I am shocked that this question has not been asked before. While there are similar topics when I click into them they always turn out to be a similar but unrelated topic.

 

 

Many thanks for any assistance!

 

Rich

TOPICS
PDF forms

Views

2.3K

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

Participant , Jun 12, 2020 Jun 12, 2020

Use this in your calculation script for each text field in question:

if ( event.target.value == "") {
event.target.borderColor = color.red;
} else {
event.target.borderColor = color.transparent;
}

Votes

Translate

Translate
Participant ,
Jun 12, 2020 Jun 12, 2020

Copy link to clipboard

Copied

Use this in your calculation script for each text field in question:

if ( event.target.value == "") {
event.target.borderColor = color.red;
} else {
event.target.borderColor = color.transparent;
}

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
Participant ,
Jun 12, 2020 Jun 12, 2020

Copy link to clipboard

Copied

Also, your code has a >= condition and an = condition both checking for no entry. This will not work as it will always drop out of the with a transparent border regardless of there is a value in the field or not.

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 Beginner ,
Jun 12, 2020 Jun 12, 2020

Copy link to clipboard

Copied

Actually the wierd thing is that my initial code started them off as red and then wouldn't revert them to red once I cleared the value. Thank you for the code you provided. I had tested that (or something similar) but I had always used the get.thisfield....

 

Appreciate the quick response.

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
Participant ,
Jun 12, 2020 Jun 12, 2020

Copy link to clipboard

Copied

Sure thing! When referencing the field in code in that field I use "event.target", not "this.getField". The beauty of that in your case is it can easily be duplicated across the rest of your fields doing the same thing.

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 ,
Jun 12, 2020 Jun 12, 2020

Copy link to clipboard

Copied

That is not weird, as you were assigning the empty string value to the field by using the wrong operator, and therefore that condition was always true, so the stroke color was always red.

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
Participant ,
Jun 12, 2020 Jun 12, 2020

Copy link to clipboard

Copied

LATEST

Same thing I said.

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