Close the UI for invalid 'time' values too

Signed-off-by: Deven Bansod <devenbansod.bits@gmail.com>
This commit is contained in:
Deven Bansod 2016-10-27 08:02:37 +05:30
parent 11575ad959
commit 95c23da6e0

View File

@ -4948,10 +4948,18 @@ function PMA_ignorePhpErrors(clearPrevErrors){
* by the Datetimepicker plugin (but is accepted by MySQL)
*/
function toggleDatepickerIfInvalid($td, $input_field) {
var dtexp = new RegExp(['^([0-9]{4})',
// 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(''));
if ($td.attr('data-type') === 'date' && ! dtexp.test($input_field.val())) {
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($input_field.val())) {
$input_field.datepicker('hide');
} else if ($td.attr('data-type') === 'time' && ! dtexpTime.test($input_field.val())) {
$input_field.datepicker('hide');
} else {
$input_field.datepicker('show');