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
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;
}
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;
}
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.
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.
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.
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.
Copy link to clipboard
Copied
Same thing I said.