mirror of
https://github.com/xdan/datetimepicker.git
synced 2024-11-18 06:24:22 +00:00
Merge pull request #426 from vzverev78/master
Improvements for validation
This commit is contained in:
commit
b6f3be4ca1
@ -575,7 +575,7 @@ var DateFormatter;
|
||||
}
|
||||
};
|
||||
})();/**
|
||||
* @preserve jQuery DateTimePicker plugin v2.5.1
|
||||
* @preserve jQuery DateTimePicker plugin v2.5.3
|
||||
* @homepage http://xdsoft.net/jqplugins/datetimepicker/
|
||||
* @author Chupurnov Valeriy (<chupurnov@gmail.com>)
|
||||
*/
|
||||
@ -1755,7 +1755,11 @@ var DateFormatter;
|
||||
if (options.allowBlank && (!$.trim($(this).val()).length || (typeof options.mask == "string" && $.trim($(this).val()) === options.mask.replace(/[0-9]/g, '_')))) {
|
||||
$(this).val(null);
|
||||
datetimepicker.data('xdsoft_datetime').empty();
|
||||
} else if (!dateHelper.parseDate($(this).val(), options.format)) {
|
||||
} else {
|
||||
var d = dateHelper.parseDate($(this).val(), options.format);
|
||||
if (d) { // parseDate() may skip some invalid parts like date or time, so make it clear for user: show parsed date/time
|
||||
$(this).val(dateHelper.formatDate(d, options.format));
|
||||
} else {
|
||||
var splittedHours = +([$(this).val()[0], $(this).val()[1]].join('')),
|
||||
splittedMinutes = +([$(this).val()[2], $(this).val()[3]].join(''));
|
||||
|
||||
@ -1767,9 +1771,7 @@ var DateFormatter;
|
||||
} else {
|
||||
$(this).val(dateHelper.formatDate(_xdsoft_datetime.now(), options.format));
|
||||
}
|
||||
|
||||
datetimepicker.data('xdsoft_datetime').setCurrentTime($(this).val());
|
||||
} else {
|
||||
}
|
||||
datetimepicker.data('xdsoft_datetime').setCurrentTime($(this).val());
|
||||
}
|
||||
|
||||
|
4
build/jquery.datetimepicker.full.min.js
vendored
4
build/jquery.datetimepicker.full.min.js
vendored
File diff suppressed because one or more lines are too long
2
build/jquery.datetimepicker.min.js
vendored
2
build/jquery.datetimepicker.min.js
vendored
File diff suppressed because one or more lines are too long
3
doc.tpl
3
doc.tpl
@ -366,7 +366,8 @@ jQuery('#_datetimepicker_weekends_disable').datetimepicker({
|
||||
<p>By default, datetimepicker uses <a href="https://github.com/kartik-v/php-date-formatter">php-date-formatter</a> for parsing and formatting the date and time displayed. You can replace the library by setting a custom DateFormatter. Simply supply an object that implements the <tt>parseDate</tt> and <tt>formatDate</tt> methods. This example uses the popular <a href="http://momentjs.com/">MomentJS</a> library:</p>
|
||||
<pre><code data-language="javascript">$.datetimepicker.setDateFormatter({
|
||||
parseDate: function (date, format) {
|
||||
return moment(date, format);
|
||||
var d = moment(date, format);
|
||||
return d.isValid() ? d : false;
|
||||
},
|
||||
|
||||
formatDate: function (date, format) {
|
||||
|
@ -1179,7 +1179,11 @@
|
||||
if (options.allowBlank && (!$.trim($(this).val()).length || (typeof options.mask == "string" && $.trim($(this).val()) === options.mask.replace(/[0-9]/g, '_')))) {
|
||||
$(this).val(null);
|
||||
datetimepicker.data('xdsoft_datetime').empty();
|
||||
} else if (!dateHelper.parseDate($(this).val(), options.format)) {
|
||||
} else {
|
||||
var d = dateHelper.parseDate($(this).val(), options.format);
|
||||
if (d) { // parseDate() may skip some invalid parts like date or time, so make it clear for user: show parsed date/time
|
||||
$(this).val(dateHelper.formatDate(d, options.format));
|
||||
} else {
|
||||
var splittedHours = +([$(this).val()[0], $(this).val()[1]].join('')),
|
||||
splittedMinutes = +([$(this).val()[2], $(this).val()[3]].join(''));
|
||||
|
||||
@ -1191,9 +1195,7 @@
|
||||
} else {
|
||||
$(this).val(dateHelper.formatDate(_xdsoft_datetime.now(), options.format));
|
||||
}
|
||||
|
||||
datetimepicker.data('xdsoft_datetime').setCurrentTime($(this).val());
|
||||
} else {
|
||||
}
|
||||
datetimepicker.data('xdsoft_datetime').setCurrentTime($(this).val());
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user