Copy link to clipboard
Copied
I am trying to add radio buttons to the if statement so that they get highlighted when not clicked on aswell
Thanks Much
var emptyFields = [];
var completedFields = [];
for (var i=0; i<this.numFields; i++) {
var f= this.getField(this.getNthFieldName(i));
var v= this.getField(this.getNthFieldName(i));
if (f.type!="button" && f.required ) {
f.strokeColor = color.black;
f.fillColor = color.white;
if ((f.type=="text" && f.value=="") || (f.type=="checkbox" && f.value=="Off") || (v.value==" ")) {
emptyFields.push(f.name);
f.strokeColor = color.red;
f.fillColor = color.white;
}
}
}
if (emptyFields.length>0) {
app.alert("Error! You must fill in all required fields (Highlighted in red)");
}
Try the following. I removed some extraneous stuff and formatted it for readability.
var emptyFields = [];
for (var i = 0; i < numFields; i++) {
var f = getField(getNthFieldName(i));
if (f.type != "button" && f.required ) {
f.strokeColor = color.black;
if (
(f.type == "text" && f.valueAsString == "")
|| (f.type == "checkbox" && f.valueAsString == "Off")
|| (f.type == "radiobutton" && f.valueAsString == "Off")
|| (f.type == "combo
...Copy link to clipboard
Copied
I am still struggling with this any help would be greatly appreciated
Copy link to clipboard
Copied
I tried f.type=="radio" && f.value=="Off" as another or statement but this doesnt work
Copy link to clipboard
Copied
Try the following. I removed some extraneous stuff and formatted it for readability.
var emptyFields = [];
for (var i = 0; i < numFields; i++) {
var f = getField(getNthFieldName(i));
if (f.type != "button" && f.required ) {
f.strokeColor = color.black;
if (
(f.type == "text" && f.valueAsString == "")
|| (f.type == "checkbox" && f.valueAsString == "Off")
|| (f.type == "radiobutton" && f.valueAsString == "Off")
|| (f.type == "combobox" && f.valueAsString == " ")) {
emptyFields.push(f.name);
f.strokeColor = color.red;
}
}
}
if (emptyFields.length > 0) {
app.alert("Error! You must fill in all required fields (Highlighted in red)");
}
Copy link to clipboard
Copied
Thanks a ton i knew all i was doing was using the wrong naming conventions. although yours is much prettier and probably much more effecient. Worked like a charm!
Find more inspiration, events, and resources on the new Adobe Community
Explore Now