Copy link to clipboard
Copied
I have two text Fields "Account#" and "Zip" that I have made mandatory when checking one of two boxes (COD Or 3rd Party), Now when checking these boxes the Fields "Account#" and "Zip" outline in red to signify these are now required fields. What I'm trying to do is then write a script for the "Account#" and "Zip" fields that then removes that outline once the fields have a value, however I also want these fields to go back to being outlined in red if the value in each field has been removed only if the "3rd Party" or "COD" boxes are still checked.
here is the javascript I have written for each checkbox
this.getField("Account#").required = event.target.isBoxChecked(0);
this.getField("Zip").required = event.target.isBoxChecked(0);
Here is the javascript I have written for each "Account#" and "Zip" field to add/remove the red required border
if(event.value != ""){
event.target.required = false;
}
else {
event.target.required = true;
}
the problem lies here, I need to modify this to only work if either "3rd Part" or "COD" box is checked. Right now the box outline will add/remove even if the boxes are not checked.
Have something to add?