JavaScript
Dateconstrain Method
Syntax
Date.constrain(settings)
Arguments
- settingsobject
The constraint settings.
- minstringdate
The minimum allowed date.
- maxstringdate
The maximum allowed date.
- formatstring
If the min and/or max dates are a string, this will specify the format the date is in. If no format is specified the default format in A5.d.date.format will be used. See Date.toFormat for a full list of format values.
Description
Extension to the native date variable to allow the date variable to be constrained to a min and/or max.
Example
var d = new Date(2018,7,10); var minD = new Date(2018,6,1); var maxD = '6/30/2018'; d.constrain({min: minD}); // d = Date(2018,7,10) d.constrain({min: minD, max: maxD, format: 'MM/dd/yyyy'}); // d = Date(2018,6,30)