The date picker controls give you a minimum / maximum, and for anything else the validate event:
UI Toolkit (Spark) Date Time Picker - options Minimum date / Maximum date accept a formula, so "today" is new Date(); the picker greys out earlier days and refuses typed values:
// Date Time Picker "DueDate" > Configuration > Minimum date (formula)
new Date(new Date().setHours(0,0,0,0))
// or at run time from a script / event
${DueDate}.setMinDate ? ${DueDate}.setMinDate(new Date()) : ${DueDate}.context.options.minDate.set("value", new Date());Heritage / Coaches toolkit Date Selector (Dojo) (BPM 8.5.7 "Date Time Picker" of the old toolkit) - no min option; set it on the underlying Dojo widget in the view's load event:
// coach view load handler wrapping the old Date Time Picker
var _this = this;
require(["dijit/registry"], function (registry) {
var node = _this.context.element.querySelector(".dijitDateTextBox");
var widget = node && registry.byNode(node);
if (widget) widget.constraints = { min: new Date() }; // disables previous dates in the calendar
});Server-side safety: validate again in the coach validation script (if (new Date(tw.local.dueDate) < today) tw.system.coachValidation.addValidationError("tw.local.dueDate", "Date must not be in the past")) - client rules can be bypassed. For blacking out weekends / holidays see question 145.
References