Copy link to clipboard
Copied
I have 3 fields, let's call them T1, T2, T3. If T1 is filled/used, then I want T2 and T3 to be read only. But if the content of T1 is deleted again, then I want T2 and T3 to be editable again.
For T1, I implemented the following code in the OnBlur action:
var t1 = this.getField("T1").value;
if (!(t1 = "")) {
this.getField("T2").readonly = true;
this.getField("T3").readonly = true;
} else {
this.getField("T2").readonly = false;
this.getField("T3").readonly = false;
}
The problem I'm noticing is, that as soon as I fill text into T1 and then delete it afterwards, the script still treats it as if there is some content in T1. So, I guess there is some sort of special hidden character in there that I need to do a check for. Any ideas?
I also already tried to use valueAsString, just in case this would remove complications, but it doesn't.
Because in an if condition, equality is noted with a double equal sign.
You would have to write this:
if (!(t1 == "")) {
Copy link to clipboard
Copied
I just found the work around that I can use t1.length > 0 to check if it contains content, but does anyone know why !(t1 = "") doesn't work?
Copy link to clipboard
Copied
Because in an if condition, equality is noted with a double equal sign.
You would have to write this:
if (!(t1 == "")) {
Copy link to clipboard
Copied
oh boy... sad that I overlook that. Thanks for the hint 🙂
Copy link to clipboard
Copied
Search for "JavaScript Comparison Operators" on this page: https://www.w3schools.com/js/js_operators.asp