mirror of
https://github.com/jquery/jquery-ui.git
synced 2025-01-07 20:34:24 +00:00
Datepicker: Added option, "constrainInput" to restrict input text to the current date format.
This commit is contained in:
parent
46cdf1377c
commit
212a822c48
@ -124,7 +124,8 @@ function Datepicker() {
|
||||
rangeSelect: false, // Allows for selecting a date range on one date picker
|
||||
rangeSeparator: ' - ', // Text between two dates in a range
|
||||
altField: '', // Selector for an alternate field to store selected dates into
|
||||
altFormat: '' // The date format to use for the alternate field
|
||||
altFormat: '', // The date format to use for the alternate field
|
||||
constrainInput: true // The input is constrained by the current date format
|
||||
};
|
||||
$.extend(this._defaults, this.regional['']);
|
||||
this.dpDiv = $('<div id="' + this._mainDivId + '" style="display: none;"></div>');
|
||||
@ -520,9 +521,11 @@ $.extend(Datepicker.prototype, {
|
||||
/* Filter entered characters - based on date format. */
|
||||
_doKeyPress: function(e) {
|
||||
var inst = $.datepicker._getInst(e.target);
|
||||
var chars = $.datepicker._possibleChars($.datepicker._get(inst, 'dateFormat'));
|
||||
var chr = String.fromCharCode(e.charCode == undefined ? e.keyCode : e.charCode);
|
||||
return e.ctrlKey || (chr < ' ' || !chars || chars.indexOf(chr) > -1);
|
||||
if ($.datepicker._get(inst, 'constrainInput')) {
|
||||
var chars = $.datepicker._possibleChars($.datepicker._get(inst, 'dateFormat'));
|
||||
var chr = String.fromCharCode(e.charCode == undefined ? e.keyCode : e.charCode);
|
||||
return e.ctrlKey || (chr < ' ' || !chars || chars.indexOf(chr) > -1);
|
||||
}
|
||||
},
|
||||
|
||||
/* Pop-up the date picker for a given input field.
|
||||
|
Loading…
Reference in New Issue
Block a user