Fix #18330 - Solved Uncaught TypeError when no-datetime field is modified
Signed-off-by: cbasguti <sebastian.gutierrezj@udea.edu.co>
This commit is contained in:
parent
3274f87b63
commit
8682e02f6b
@ -4400,21 +4400,24 @@ Functions.ignorePhpErrors = function (clearPrevErrors) {
|
||||
* @param $inputField
|
||||
*/
|
||||
Functions.toggleDatepickerIfInvalid = function ($td, $inputField) {
|
||||
// Regex allowed by the Datetimepicker UI
|
||||
var dtexpDate = new RegExp(['^([0-9]{4})',
|
||||
'-(((01|03|05|07|08|10|12)-((0[1-9])|([1-2][0-9])|(3[0-1])))|((02|04|06|09|11)',
|
||||
'-((0[1-9])|([1-2][0-9])|30)))$'].join(''));
|
||||
var dtexpTime = new RegExp(['^(([0-1][0-9])|(2[0-3]))',
|
||||
':((0[0-9])|([1-5][0-9]))',
|
||||
':((0[0-9])|([1-5][0-9]))(.[0-9]{1,6}){0,1}$'].join(''));
|
||||
// If the Datetimepicker UI is not present, return
|
||||
if ($inputField.hasClass('hasDatepicker')) {
|
||||
// Regex allowed by the Datetimepicker UI
|
||||
var dtexpDate = new RegExp(['^([0-9]{4})',
|
||||
'-(((01|03|05|07|08|10|12)-((0[1-9])|([1-2][0-9])|(3[0-1])))|((02|04|06|09|11)',
|
||||
'-((0[1-9])|([1-2][0-9])|30)))$'].join(''));
|
||||
var dtexpTime = new RegExp(['^(([0-1][0-9])|(2[0-3]))',
|
||||
':((0[0-9])|([1-5][0-9]))',
|
||||
':((0[0-9])|([1-5][0-9]))(.[0-9]{1,6}){0,1}$'].join(''));
|
||||
|
||||
// If key-ed in Time or Date values are unsupported by the UI, close it
|
||||
if ($td.attr('data-type') === 'date' && ! dtexpDate.test($inputField.val())) {
|
||||
$inputField.datepicker('hide');
|
||||
} else if ($td.attr('data-type') === 'time' && ! dtexpTime.test($inputField.val())) {
|
||||
$inputField.datepicker('hide');
|
||||
} else {
|
||||
$inputField.datepicker('show');
|
||||
// If key-ed in Time or Date values are unsupported by the UI, close it
|
||||
if ($td.attr('data-type') === 'date' && ! dtexpDate.test($inputField.val())) {
|
||||
$inputField.datepicker('hide');
|
||||
} else if ($td.attr('data-type') === 'time' && ! dtexpTime.test($inputField.val())) {
|
||||
$inputField.datepicker('hide');
|
||||
} else {
|
||||
$inputField.datepicker('show');
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user