Skip to content

Commit 895d27f

Browse files
Added change by mikedeco in _onTimeChange. Assures that hour, minute, second is numeric
1 parent 3d53741 commit 895d27f

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

jquery-ui-timepicker-addon.js

+8-3
Original file line numberDiff line numberDiff line change
@@ -524,9 +524,14 @@ $.extend(Timepicker.prototype, {
524524
_onTimeChange: function() {
525525
var hour = (this.hour_slider) ? this.hour_slider.slider('value') : false,
526526
minute = (this.minute_slider) ? this.minute_slider.slider('value') : false,
527-
second = (this.second_slider) ? this.second_slider.slider('value') : false,
528-
ampm = (hour < 12) ? 'AM' : 'PM';
529-
527+
second = (this.second_slider) ? this.second_slider.slider('value') : false;
528+
529+
if (hour) hour = parseFloat(hour).toFixed(0);
530+
if (minute) minute = parseFloat(minute).toFixed(0);
531+
if (second) second = parseFloat(second).toFixed(0);
532+
533+
var ampm = (hour < 12) ? 'AM' : 'PM';
534+
530535
// If the update was done in the input field, the input field should not be updated.
531536
// If the update was done using the sliders, update the input field.
532537
var hasChanged = (hour != this.hour || minute != this.minute || second != this.second || (this.ampm.length > 0 && this.ampm != ampm));

0 commit comments

Comments
 (0)