Quick question about the Dijit.Form.DateTextBox
http://docs.dojocampus.org/dijit/form/DateTextBox
This page contains the following: “also validates against developer-provided constraints like min, max, valid days of the week, etc.”
I can’t seem to find documentation allowing me to provide a constraint on the days of the week. For instance, i need to have a DateTextBox which only allows users to choose a date that occurs on a Sunday.
I’d appreciate any help with this. Thanks!
I looked heavily into the source code for this, and I think the manual may be misleading you a bit – there’s no way to do this using the object’s constraints. The following quote from their user forums seems to back up my findings:
You can see an example of such a subclass of DateTextBox at http://dojotoolkit.org/forum/dijit-dijit-0-9/dijit-support/datetextbox-mondays-only-selectable#comment-19508.
If that’s too much work for you, DateTextBox DOES descend from dijit.form.ValidationTextBox, so we can use this widget’s regExpGen to create a validator – it won’t prevent us from selecting invalid dates, but it will cause dijit to mark the widget as invalid and give the user a ‘The value entered is not valid’.
dijit.byId('toDate').regExpGen = function() { if (dojo.date.locale.format(this.value, {datePattern: "E", selector: "date"}) == 6) return ".*"; return "0"; }