Expand my Community achievements bar.

SOLVED

Cannot reset border of subform?

Avatar

Level 7

I am modifying the ColorFieldsValidation JavaScript to handle a situation where I want the entire subform containing any failed fields to be highlighted. The highlighting works well. However, even when the validation is successful, the highlighting persists. I believe I've narrowed it down to line 32, which seems to only remove the bottommost border. I realize this code was originally written to remove borders of fields, but why does it not also work for subforms?


function InitializeColorFields() {


    // Disable Acrobat's field highlighting. The Color


    // Failed Fields action takes care of highlighting fields.


    if (xfa.host.name == "Acrobat") {


        app.runtimeHighlight = false;


    }


}


function DoColorFields(oInvalidNode) {


    // If this form is running on a client other than Acrobat


    // (like on the server) then don't run this script


    if (xfa.host.name != "Acrobat") {


        return;


    }


    var sClassName = oInvalidNode.className;


  


    // Only contests, so nodes that are <field>s and


    // have name "Selected"


    // Ignore everything else


    if ((sClassName != "field") &&


        (oInvalidNode.name != "Selected")) {


        return;


    }


  


    //get closest Contest


    var nearestContest = oInvalidNode.resolveNode("Contest")


    if (oInvalidNode.errorText == "") {      


        // Validation Succeeded


        // Revert the appearance to its original state          


        console.println("we good for " + oInvalidNode.name);


        var oBorder = nearestContest.border;


        //does not work!      


        oBorder.parent.nodes.remove(oBorder);          


              


    }


    else {      


        // Validation Failed


        // Show the invalid appearance


        var oFailedBorder = nearestContest.border;


        // Border color


        // Show a solid border with square corners


        var sBorderColor;


            sBorderColor = "51, 102, 255";  


        if (sBorderColor != "none") {


      


            oFailedBorder.presence = "visible";


          


            for (var i = 0; i < 4; i++) {


                var oEdge = oFailedBorder.getElement("edge", i);


              


                oEdge.presence = "visible";


                oEdge.color.value = sBorderColor;


                oEdge.thickness = "2pt";


                oEdge.stroke = "solid";


              


                var oCorner = oFailedBorder.getElement("corner", i);


      


                oCorner.presence = "visible";


                oCorner.color.value = sBorderColor;


                oCorner.thickness = "2pt";


                oCorner.stroke = "solid";


                oCorner.join = "square";


                oCorner.inverted = "0";


                oCorner.radius = "0mm";


            }


        }



        // Background color


        // Show a solid fill color


        var sFillColor;      


        sFillColor = "153, 204, 255";



        if (sFillColor != "none") {


            // The presence of the border must be visible to show the fill.


            // Hide the edges when the invalid appearance doesn't include


            // changing the border color


            if (oFailedBorder.presence != "visible") {


                oFailedBorder.presence = "visible";


                oFailedBorder.edge.presence = "invisible";


            }


          


            // Replace the current fill type with a solid fill


            if (oFailedBorder.fill.oneOfChild.className != "solid") {


                var oFailedFillType = oFailedBorder.fill.oneOfChild;


                oFailedBorder.fill.nodes.remove(oFailedFillType);


              


                var oSolid = xfa.form.createNode("solid", "");          


                oFailedBorder.fill.nodes.append(oSolid);


            }


            oFailedBorder.fill.color.value = sFillColor;


        }      


    }


}



An example demonstrating this issue is here: Shared Files - Acrobat.com

1 Accepted Solution

Avatar

Correct answer by
Level 7

I "fixed" this issue by changing line 32 to this:

xfa.resolveNode(nearestContest.border.somExpression).presence = "invisible";

It seems that unlike a field's border, a subform's border cannot be removed.

View solution in original post

1 Reply

Avatar

Correct answer by
Level 7

I "fixed" this issue by changing line 32 to this:

xfa.resolveNode(nearestContest.border.somExpression).presence = "invisible";

It seems that unlike a field's border, a subform's border cannot be removed.