Fix JS number validation when the input is empty

Signed-off-by: William Desportes <williamdes@wdes.fr>
This commit is contained in:
William Desportes 2023-11-12 18:22:44 +01:00
parent b5743c691a
commit 85624b9115
No known key found for this signature in database
GPG Key ID: 90A0EF1B8251A889

View File

@ -178,6 +178,9 @@ function verifyAfterSearchFieldChange (index, searchFormId) {
// BETWEEN and NOT BETWEEN
// See all possible syntaxes in tests of https://regexr.com/7h1eq
jQuery.validator.addMethod('validationFunctionForMultipleInt', function (value) {
if (value === '') {
return true;
}
return value.replace(/ /g,'').match(/^(((0x[0-9a-f]+)|([+-]?([0-9]*\.?[0-9]+|[0-9]+\.?[0-9]*)(e[+-]?[0-9]+)?))(,|$))+$/i) !== null;
},
Messages.strEnterValidNumber
@ -187,6 +190,10 @@ function verifyAfterSearchFieldChange (index, searchFormId) {
// validator method for INTs
// See all possible syntaxes in tests of https://regexr.com/7h1ci
jQuery.validator.addMethod('validationFunctionForInt', function (value) {
if (value === '') {
return true;
}
return value.match(/^(0x[0-9a-f]+$)|([+-]?([0-9]*\.?[0-9]+|[0-9]+\.?[0-9]*)(e[+-]?[0-9]+)?)$/i) !== null;
},
Messages.strEnterValidNumber