Skip to main content
RichiRichEH!
Participant
June 12, 2020
Answered

Changing Text Box Border Color to transparent once text is entered

  • June 12, 2020
  • 1 reply
  • 3615 views

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

This topic has been closed for replies.
Correct answer Old_Salt

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;
}

1 reply

Old_Salt
Old_SaltCorrect answer
Participating Frequently
June 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;
}

Old_Salt
Participating Frequently
June 12, 2020

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.

RichiRichEH!
Participant
June 12, 2020

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.