Jun 12, 2014, 12:15 PM
90 Posts

Conditional validation: make a field required only if report is being submitted as final

  • Category: Server Side JavaScript
  • Platform: All
  • Release: 9.0.1
  • Role: Developer
  • Tags: Validation
  • Replies: 1

I want the follow validation to kick in *only* if the Report.Status field = 'Final'. (The users are allowed to submit the report as draft and come back and finish it later.)

How would I go about this?

        <xp:inputTextarea style="width:75%" value="#{Report.Agenda}" id="Agenda">
                                <xp:this.validators>
                        <xp:validateRequired
                            message="Question 1 can't be blank">
                        </xp:validateRequired><!-- (1)  -->
                    </xp:this.validators>
        </xp:inputTextarea>

Jun 13, 2014, 12:35 AM
110 Posts
Didn't the inputTextArea required checkbox can be computed?

I haven't tested but instead of ticking the "Required field" of the inputTextArea, maybe you can just compute the following SSJS into it:

Report.getValue("Status") == "Final"