Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Removed the validation example because it does not work

...

Note that validation is applied when you exit a field/question (or try to skip past it). Therefore any fields in hidden sections or questions will not be validated. (E.g. it is safe to put "required" validation on a field that is only required when its section is shown.)

Code Block
languagejs
titleExample of Numeric Range
"fields": [
                                	{
                                    "type": "obs",
                                    "formFieldName": "obs.5089AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA",
                                    "label": "Weight",
                                    "widget": {
                                        "providerName": "uicommons",
                                        "fragmentId": "field/text",
                                        "config": {
                                            "min": "0.5",
                                            "max": "199",
                                            "appendToValueDisplayed": "kg"
                                        }
                                    },
                                    "cssClasses": [ "number", "numeric-range" ]
                                }
                            ]

 

Non-Standard Display/Value

...

Code Block
languagejs
titleFunction to Hide Fields on form load
<script type="text/javascript">
jQuery(function() { 
	htmlForm.simpleUi.hideQuestion('ENTER_FIELDSET_ID');
	htmlForm.simpleUi.hideQuestion('ENTER_FIELDSET_ID');
	});
</script>

The examples page shows a fully worked out example showing two questions that are hidden when the page loads and then are displayed if the user selects "No" or "Refused to Answer"

...

You can only dynamically hide one field (<p>) at a time. If you have multiple fields that need to be hidden, it's best to place these fields in a <fieldset> and use the htmlForm.simpleUi.showQuestion('id-on-fieldset-tag') function. For example, we often have multiple observations when the user selects "other" from a coded concept dropdown menu. We then ask the user to specify the "Other" option in a text box. This occasion would only require hiding one field (<p>). Let's take it a step further and say you want to ask a yes/no coded concept that shows another coded concept with an "Other" coded response that asks the user to specify what they mean when selecting "Other" from the second dropdown observation. In this case, you would have to place the second coded concept and "Specify Other" concept within a <fieldset> and use the showQuestion function. Then, you can use the showField function on the second coded concept to dynamically display the "Specify Other" text field.

The examples page shows a complex example that uses the showQuestion function to display a simulated select-multiple question set:

...