FORUM PLAN UPDATE
Date revision: This forum will remain open to new posts and responses until December 1, 2018. (After that date, you will still be able to view and search the forum.) Also, we're taking a second look at the best place to host future conversation. For now, keep using this forum, and stay tuned for more news.



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"


FORUM PLAN UPDATE
Date revision: This forum will remain open to new posts and responses until December 1, 2018. (After that date, you will still be able to view and search the forum.) Also, we're taking a second look at the best place to host future conversation. For now, keep using this forum, and stay tuned for more news.