mirror of
https://github.com/jquery/jquery-ui.git
synced 2024-11-21 11:04:24 +00:00
Datepicker: Fixed #3861 Manually entered date does not update altField
This commit is contained in:
parent
62f11b4a2e
commit
8f503d8d31
@ -452,6 +452,17 @@ test('altField', function() {
|
|||||||
inp.simulate('keydown', {ctrlKey: true, keyCode: $.simulate.VK_END});
|
inp.simulate('keydown', {ctrlKey: true, keyCode: $.simulate.VK_END});
|
||||||
equals(inp.val(), '', 'Alt field - dp - ctrl+end');
|
equals(inp.val(), '', 'Alt field - dp - ctrl+end');
|
||||||
equals(alt.val(), '', 'Alt field - alt - ctrl+end');
|
equals(alt.val(), '', 'Alt field - alt - ctrl+end');
|
||||||
|
// Verify alt field is updated on keyup
|
||||||
|
alt.val('');
|
||||||
|
inp.val('06/04/2008').datepicker('show');
|
||||||
|
inp.simulate('keyup', {keyCode: $.simulate.VK_ENTER});
|
||||||
|
equals(inp.val(), '06/04/2008', 'Alt field - dp - manual entry');
|
||||||
|
equals(alt.val(), '2008-06-04', 'Alt field - manual entry');
|
||||||
|
// Verify alt field is not updated on keyup if date is invalid
|
||||||
|
inp.val('12/04/');
|
||||||
|
inp.simulate('keyup', {keyCode: $.simulate.VK_ENTER});
|
||||||
|
equals(inp.val(), '12/04/', 'Alt field - dp - manual entry incomplete');
|
||||||
|
equals(alt.val(), '2008-06-04', 'Alt field - manual entry - not updated');
|
||||||
});
|
});
|
||||||
|
|
||||||
test('daylightSaving', function() {
|
test('daylightSaving', function() {
|
||||||
|
@ -198,7 +198,8 @@ $.extend(Datepicker.prototype, {
|
|||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
input.addClass(this.markerClassName).keydown(this._doKeyDown).keypress(this._doKeyPress).
|
input.addClass(this.markerClassName).keydown(this._doKeyDown).
|
||||||
|
keypress(this._doKeyPress).keyup(this._doKeyUp).
|
||||||
bind("setData.datepicker", function(event, key, value) {
|
bind("setData.datepicker", function(event, key, value) {
|
||||||
inst.settings[key] = value;
|
inst.settings[key] = value;
|
||||||
}).bind("getData.datepicker", function(event, key) {
|
}).bind("getData.datepicker", function(event, key) {
|
||||||
@ -286,7 +287,8 @@ $.extend(Datepicker.prototype, {
|
|||||||
$target.removeClass(this.markerClassName).
|
$target.removeClass(this.markerClassName).
|
||||||
unbind('focus', this._showDatepicker).
|
unbind('focus', this._showDatepicker).
|
||||||
unbind('keydown', this._doKeyDown).
|
unbind('keydown', this._doKeyDown).
|
||||||
unbind('keypress', this._doKeyPress);
|
unbind('keypress', this._doKeyPress).
|
||||||
|
unbind('keyup', this._doKeyUp);
|
||||||
} else if (nodeName == 'div' || nodeName == 'span')
|
} else if (nodeName == 'div' || nodeName == 'span')
|
||||||
$target.removeClass(this.markerClassName).empty();
|
$target.removeClass(this.markerClassName).empty();
|
||||||
},
|
},
|
||||||
@ -511,6 +513,27 @@ $.extend(Datepicker.prototype, {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/* Synchronise manual entry and alternate field. */
|
||||||
|
_doKeyUp: function(event) {
|
||||||
|
var inst = $.datepicker._getInst(event.target);
|
||||||
|
if (!$.datepicker._get(inst, 'altField'))
|
||||||
|
return true;
|
||||||
|
try {
|
||||||
|
var date = $.datepicker.parseDate($.datepicker._get(inst, 'dateFormat'),
|
||||||
|
(inst.input ? inst.input.val() : null),
|
||||||
|
$.datepicker._getFormatConfig(inst));
|
||||||
|
if (date) { // only if valid
|
||||||
|
$.datepicker._setDateFromField(inst);
|
||||||
|
$.datepicker._updateAlternate(inst);
|
||||||
|
$.datepicker._updateDatepicker(inst);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (event) {
|
||||||
|
$.datepicker.log(event);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
},
|
||||||
|
|
||||||
/* Pop-up the date picker for a given input field.
|
/* Pop-up the date picker for a given input field.
|
||||||
@param input element - the input field attached to the date picker or
|
@param input element - the input field attached to the date picker or
|
||||||
event - if triggered by focus */
|
event - if triggered by focus */
|
||||||
|
Loading…
Reference in New Issue
Block a user