Javascript validation of fill-in choice control

Hello All,

I have a form which has a number of dropdown choice controls which allow for "fill-in" text entry as well.  Some of these controls need to have conditional validations rules set (i.e. if choice above = "xxx" then this is required") and i am trying to figure out the correct javascript syntax to do so.  

I can easily use javascript to conditionally validate the control to check if no dropdown selection has been made, but how can I access the "fill-in" entry box to check if that is Null when the corresponding radio box is selected...

See pic below for example...

Hope someone can point me in the right direction

0 Kudos
1 Reply

Re: Javascript validation of fill-in choice control

Just using the Named Control in your formula will result in the value of whichever field (Drop Down -or- Fill In) is currently selected. 

You can see this easily simply using the Named Control as the formula for a Calculated Control, and looking at the output. 

(Naming a choice control)

(Adding the Named Control reference to a Calculated Control's Formula)

(Showing the value when an option is selected and active)

(Showing the value when the fill in is active) 

So, as shown, using the Referenced Named Control of the Choice in question will always result in the correct value being passed to your Rule. 

If you're trying to figure out which portion of the control is active (the Fill In section or the default Choice section), you'll need to break out the javascript, and because I'm not sure how you have your rules set up, it would be a bit difficult to give you an adequate explanation otherwise. 

Ultimately, this: 

NWF$("#" + optionsID).siblings(".nf-choice-control-radio-button").find("input").prop("checked")

will tell you whether or not the top 'Default Choice' control is active, but again, how you use that is entirely up to how your rules are set up. 

It should be noted that this assumes you have the 'Store Client ID in Javascript Variable' option set to Yes and the variable name set to 'optionsID' 


0 Kudos