Prompt Complete Text Field if Drop-down Value in Another Field Selected

  • 23 September 2017
  • 8 replies
  • 3 views

Badge +1

In SharePoint list have column with Choice column with three selections. In another column, simple text field, want user to enter value if selects any of three choices. Have tried various ways to prompt the user to enter a value in the text field--all without success. ArcherFolders=='Select'&&isNullOrEmpty({Self}), my message box contains brief "Enter Subfolder Name".

Most promising was this solution: https://ootbtutorials.com/2016/02/16/validating-or-requiring-fields-on-nintex-forms/ but cannot make work. What am I doing wrong and is there another simple way to get same or better result? Thanks


8 replies

Badge +6

This should work :

not(isNullOrEmpty(ArcherFolders)) && isNullOrEmpty({Self})
Badge +1

I appreciate your help but the solution did not work and I don't know why. One thing I did not mention, and may be of consequence, I have ArcherFolders control set to Appearance, Use custom "Please select" text to Yes. and Custom "please select" text set to Select. Could it be that your solution is being negated by my Select? I removed it but still the rule fails to fire. To clarify I want the user to select one of three values from AcherFolders any of which must prompt user to then complete a blank text field immediately below ArcherFolders. Best-

Userlevel 5
Badge +13

Is your rule type "formatting" or "validation"?

208014_pastedImage_1.png

Also, are you selecting your "ArcherFolders" from the "Item Properties" or "Named Controls"? It needs to be the latter to be dynamic during filling out the form.

Badge +6

The Rule will execute once the Save/Submit button is clicked.

But if you want an alert (prompt) right after the drop down change , you can achieve that using Custom JavaScript.

Note : varArcherFolders and varSubFolderName are the Client ID JavaScript variable names.

NWF$(document).ready(function () {
NWF$('#' + varArcherFolders).change(function () {
var ArcherFolders = NWF$('#' + varArcherFolders).val();
var SubFolder = NWF$('#' + varSubFolderName).val();
if((ArcherFolders != "**SelectValue**") && (SubFolder == ''))
{
alert("Enter Subfolder Name");
}
});
});

Badge +1

Did as understood your directions and still no alert--and yes pulling from Named Controls for only there do I see {Self}. Below my doings. Are they as per your instructions or have I got it wrong? Thanks-

Rule, Type FormattingJavaScript

Userlevel 5
Badge +13

What component do you have this rule applied to? 

Let me make sure I understand your requirements:

When someone selects a choice from the dropdown on ArcherFolders you want:

  1. A text field to become required
  2. A message to appear that says "please enter subfolder name"

Is that right? If so, you will need to have two rules; one that makes the text field required, and one that will make the message appear. The way to think about the condition part of the rules, is "if this condition evaluates to true, I'm going to [do thing]." So you want when ArcherFolders is not empty, for the text field to be required, which would mean the text field can't be empty. So, you would have a rule that has "Rule Type" of "Validation" for this. and the condition is not(isNullOrEmpty(ArcherFolders)) && isNullOrEmpty({Self}), you would apply that rule to the text field. If you enter something in the "message" field, it will appear if they try to click submit, that the control is required, but not before.

If you want a message to appear as soon as they select from the dropdown, then you can create a label control with your message and place it near your text box. Have a rule of type "Formatting" on that one and check the "Hidden" checkbox. Then the logic should be not(isNullOrEmpty(ArcherFolders)). This will say when this field is not empty (so something was selected) then show this message.

Badge +1

Courtney your understanding is correct. To my original formatting rule I have added a validation rule. I added the rule to the existing label titled SubfolderName associated with SubfolderName control. I ''re-used" that label for when I created a new label control with that name then on attempting to preview the form it failed to load. Does that conform to your instructions? As well, do I keep Saud's JavaScript or given that am now using two rules do I delete it? So, assuming I understood your instructions and executed correctly I have two rules--Formatting with Hide checked and JavaScript intact. Nothing changed. No message appeared when selecting dropdown. Thanks-

Userlevel 5
Badge +13

No worries! Can you show me some screenshots of your form designer? And show each rule and the controls it's attached to? With the method I'm describing you would not need the Javascript.

Reply