From 6e88cbabd4feeaa4dc2360b7a649a92395d2e333 Mon Sep 17 00:00:00 2001 From: William Desportes Date: Fri, 14 Jul 2023 11:17:39 +0200 Subject: [PATCH] Fix #18325 - Allow hex representations for integers - Allow exponential notation - Allow +/- notation Signed-off-by: William Desportes --- js/src/table/change.js | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/js/src/table/change.js b/js/src/table/change.js index f69a10e8aa..b65f7ec0d0 100644 --- a/js/src/table/change.js +++ b/js/src/table/change.js @@ -176,13 +176,21 @@ function verifyAfterSearchFieldChange (index, searchFormId) { }); // validator method for IN(...), NOT IN(...) // BETWEEN and NOT BETWEEN + // See all possible syntaxes in tests of https://regexr.com/7h1eq jQuery.validator.addMethod('validationFunctionForMultipleInt', function (value) { - return value.match(/^(?:(?:\d\s*)|\s*)+(?:,\s*\d+)*$/i) !== null; + return value.match(/^((([+-]|0x)?([0-9]*\.?[0-9]+|[0-9]+\.?[0-9]*)([eE][+-]?[0-9]+)?(,|$))+)$/i) !== null; }, Messages.strEnterValidNumber ); validateMultipleIntField($thisInput, true); } else { + // validator method for INTs + // See all possible syntaxes in tests of https://regexr.com/7h1ci + jQuery.validator.addMethod('validationFunctionForInt', function (value) { + return value.match(/^([+-]|0x)?([0-9]*\.?[0-9]+|[0-9]+\.?[0-9]*)([eE][+-]?[0-9]+)?$/i) !== null; + }, + Messages.strEnterValidNumber + ); $(searchFormId).validate({ // update errors as we write onkeyup: function (element) { @@ -229,8 +237,8 @@ function validateIntField (jqueryInput, returnValueIfIsNumber) { jqueryInput.rules('remove'); jqueryInput.rules('add', { - number: { - param: true, + validationFunctionForInt: { + param: jqueryInput.value, depends: function () { return returnValueIfIsNumber; }