Dojo Filtering Select (xe:djFilteringSelect
) controls include client side ‘required’ validation by default. The problem is that if it fails this validation, any page submission or other server-side action will not be triggered. However, if you want to disable this validation, the built-in property of the control doesn’t work. In this post, I’ll show how to achieve the desired effect.
Creating a Filtering Select
If you’re not familiar with the Dojo Filtering Select, take a look at this post.
Validation Behavior
Take, for example, the Dojo Filtering Select that I used in a recent post about changing the search behavior of a Dojo Filtering Select:
If I clear the value in the field and tab out of it, I am presented with this error message: ‘This value is required’
The problem is that any server-side onChange error handler of the field will not fire because the field failed client-side validation.
Disabling the Required Validation
The Dojo documentation shows that adding a required
attribute and setting it to false
will disable this behavior.
There’s a required
property on the djFilteringSelect
control. Unfortunately, it has no effect when set to false
.
If you look at the HTML output, you’ll see that the field has this attribute: aria-required="true"
To get it to work, you can add the required
attribute (and set it to false
) as a Dojo attribute.
This does the job and it changes the attribute in the HTML output for the page to: aria-required="false"
