Validations for individual items in a dropdown box

  • 22 October 2018
  • 2 replies
  • 2 views

Badge +1

I have a form in Nintex that has a dropdown control with many options to choose from. My question is, is there a way to validate for individual choices selected in the dropdown. For example, if "commercial" is selected from the dropdown box can I validate a text box to recognize the selection and apply validations for the choice? Where the text box would be labeled "account #" and validated to only allow so many numeric characters.


2 replies

Userlevel 5
Badge +14

Yep! That's the point of the validation system actually!

If you had a Selection Control, we'll call it 'Customer Type', and a Single Line Text Control (we'll call it 'Account Number'): 

219645_pastedImage_2.png

Let's say we gave the Customer Type a few options: 

219646_pastedImage_3.png

Because we don't want the user to be able to submit the form without having made a selection first, we'll add a rule to the CustomerType Control using the Rule Editor: 

219740_pastedImage_4.png

Instead of typing thing into the 'Condition: Control is invalid if...' text area, click on the formula button (as shown). It will open up the Formula Builder Dialog: 

219741_pastedImage_5.png

Inside of this dialog you'll have access to all of the Runtime Functions and Control References you should need to validate that the current control ({Self}) has *some* value:

219742_pastedImage_6.png

(Note: Validation Rules are considered to be Invalid when the value returned back from the expression equals true. This is important because as the above information states for the 'isNullOrEmpty()' function, the function will return true whenever the control being evaluated contains no value!)

With just that Rule alone, we prevent the user from Submitting the Form when they haven't made a choice for the Customer Type: 

219743_pastedImage_7.png

Now we can add a second Validation Rule to the Account Number Control:

219744_pastedImage_16.png

Instead of just using the isNullOrEmpty({Control:Self}) function by itself, we also know that we ONLY want to check the Account Number Control in this way IF the CustomerType Control is equal to the value "Commercial". We do this by once again going into the Formula Builder Dialog and referencing the Named Control for our CustomerType: 

219745_pastedImage_17.png

Now that we have added this second rule, if you pick a choice for CustomerType that isn't "Commercial" and hit submit, the form will submit correctly. However if you select "Commercial" and you do not have anything in the Account Number textbox, it will throw a validation error: 

219746_pastedImage_18.png

You can get a lot more complex than this and encourage you to seek out various topics about Validation Rules here on the forum, but this should be a good primer to show you how you can accomplish what it is you're trying to do. 

Hope it helps! 

Badge +1

Thanks for the response N M. After reading it, I have zeroed in on what the question should've been... I want to "format" my single line text box ("account #") to only allow a certain amount of numeric characters for specific options picked in the dropdown box ("commercial"). Sorry for the confusion, I'm fairly new to Nintex.

Reply