Showing results for 
Search instead for 
Did you mean: 

Using validation rules to ensure a comments box is not left empty

Not applicable
25 59 54K

The Scenario: When a task is rejected, ensure the user cannot submit before including a comment.


Crestan, a business management company has discovered an issue during their annual business systems audit. Approval tasks for system documentation have been completed and marked as rejected by some managers and employees without feedback or a given reason. The General Manager has asked you to modify the form so if a task is rejected, the user must fill in the comments field.


This scenario is only applicable to the Request Approval workflow action, and is applicable to both Nintex Forms 2013 and Nintex Forms 2010.


Validation Rules were introduced in Nintex Forms released on 5th June 2014.

Nintex Forms 2013 v2.3.2.0

Nintex Forms 2010 v1.5.2.0



  • A user must be forced to enter a comment if they reject a task
  • The comment cannot be a blank value or whitespace



The comments box will display a red border and a message will display if the task was rejected and comments have not been entered.


Configure the Nintex Task Form

For the purpose of this example, we will modify the Nintex task form within a Nintex Workflow 2013 Request Approval Action.


  1. In the Workflow Actions toolbox, select the User Interaction toolbox.
  2. Drag a Request Approval action onto the design canvas.
  3. Double- click to open the dialog box. In the Ribbon, click on the Edit Task Form and select Edit with Nintex Forms.

task form.png

Add a Rule

Select the Comments text box of the task form so we can add a rule to this control and click Add Rule in the Ribbon.




Give the rule a Name “Not empty when”, and select the Rule Type as Validation.


In the Condition field, click on the Formula Builder icon. Select the Runtime Function “isNullOrEmpty”, and in the () select the Named Control, {Self}. This means “if the control on which this is running is null or empty…”




Next we add another condition to the formula when the outcome is rejected. Add “&&” and then in the Named Control tab, select Decision. The value for reject is 2, and for approve 1, so need to add ==”2”.


To find this value, you need to publish the workflow, then run it and use the F12 developer tools of your browser to find the values on those radio buttons.  If you check this value using F12 developer tools in the Nintex Forms preview, you will see both show as -1 values, this is incorrect when published and should be Reject=2 Approve=1.


The final formula should look like this, and means “this control is invalid if this field is empty and the outcome is rejected”.


isNullOrEmpty({Self}) && Decision=="2"


In the Message field, enter a message for when the form cannot be submitted.







Save the form. Now, when a user rejects a task, and tries to submit without providing a comment, a red line will appear around the comments section, and the message will appear at the top of the form.


For more examples:

Validation Rules and the People control - Nintex Forms

How to complete Date Validation using Nintex Forms 2013 Validation Rules

Formatting vs Validation Rules in Nintex Forms

Automation Master
Automation Master

Unless you have something else going on with your Decision names, the names of your controls, or the code pasted into your rule. 

Doing a quick mockup, everything is acting as it should be

Decision Control Name and Options: 

Setting the Rule:

Resulting Validation: 

Code used: 

isNullOrEmpty({Control:Self}) && NWF$("[data-controlname='Decision'] input:checked").siblings("label").text() === "Reject" 

If you have a specific case in which this is not working, can you provide more information about the Approval / Rejection / Whatever options you have set up on your flexi task so that they can be recreated? 

Nintex Newbie

I just realize I have some syntax error in my formula,  let me try again.  one question: when putting in the formula, can I just use copy /paste and change the text?  Do I need to enter via "named controls", "runtime functions"?

Nintex Newbie

I first put in this formula exactly the one you used:

isNullOrEmpty({ControlSmiley Frustratedelf}) && NWF$("[data-controlname='Decision']
input:checked").siblings("label").text() === "Reject"

It worked in terms of conditional validation based on "Reject" choice, but it had a problem, the comment box remains invalid even after I put some text in the box, it keeps the red frame and red message saying this is invalid, I can't save the form. It seems that it can't recognize {ControlSmiley Frustratedelf} means the box itself is empty.

Then I changed the {controlSmiley Frustratedelf} by selecting the {self} from "Named Controls" as follows, then it worked.

Select "Reject", the box has a red frame, I can't save. After entering text in the box, form is saved.

isNullOrEmpty({Self}) && NWF$("[data-controlname='Decision'] input:checked").siblings("label").text() === "Reject"

Thanks for your solution, it is a major help!

Automation Master
Automation Master

that's very strange. 

{ControlSmiley Frustratedelf} should automatically resolve to {Self} whenever the rule is evaluated for the first time. The only thing I can think of that may have messed that up is that sometimes, if you copy a text source that has some markup on it (for instance, text from the web, or from this here forum), it can paste that formatting into the formula editor and silently do bad things during runtime. 

I'd be interested to know what would happen if you just put a validation rule on something with the exact text (typed yourself and not copy pasted) isNullOrEmpty({ControlSmiley Frustratedelf})  and then attempted to submit the form leaving that control blank. Ideally it should throw an error, and upon looking at the Rule again, the {ControlSmiley Frustratedelf} should be replaced with the red linked version. 

(But that's only if you really care to go down that rabbit hole) 

Other than that, I'm ultimately glad that your problem was solved. You should be able to use this method to test against any number of Outcome Decisions for future tasks. 

Nintex Newbie

Hi - in my form I have 2 buttons: 'Save & Close' and 'Submit', and both button actions are set to 'Save and Submit'.  I have found that the validation rule works when I hit the 'Save & Close' button, but not the 'Submit', and I'm not sure why when they both have the same action.

Has anyone else had this issue?  And if so, how was it resolved?

Thank you!

Nintex Newbie

Sorry... I checked again and there was an old formula on the 'Submit' button that was running on Client click and I guess, interrupting the validation process.

Nintex Newbie

I ran into problem again.  the rules I built in March on a multi-outcome task form is broken by nintex form and Now I have to rebuild.

I got one formula working: 

isNullOrEmpty({Self}) && NWF$("[data-controlname='Decision'] input:checked").siblings("label").text() === "B"

I need to set a rule on another box to make it mandatory if A or C is selected.  Can someone help me on the formula this rule?

Nintex Newbie

I got the 2nd rule formula to work.  It is same as the first formula, except for the end, "..... text()=== "A" || "C". 

Problem solved!

Nintex Newbie

Is this working for Nintex workflow 2010? We have a Nintex workflow 2010 and requires if a task is rejected, ensure the user cannot submit before including a comment.