From 732cac6ad8067c0c81d5295987fb1141b7a4d064 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Pochat?= Date: Thu, 11 Sep 2025 12:42:41 +0200 Subject: [PATCH] Apply number instead of string comparison --- war/src/main/webapp/scripts/hudson-behavior.js | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/war/src/main/webapp/scripts/hudson-behavior.js b/war/src/main/webapp/scripts/hudson-behavior.js index 92a6bd9745b8..f9e53754f9a5 100644 --- a/war/src/main/webapp/scripts/hudson-behavior.js +++ b/war/src/main/webapp/scripts/hudson-behavior.js @@ -821,16 +821,16 @@ function registerMinMaxValidator(e) { } if (isInteger(this.value)) { + const valueInt = parseInt(this.value); + // Ensure the value is an integer if (min !== null && isInteger(min) && max !== null && isInteger(max)) { // Both min and max attributes are available - - if (min <= max) { + const minInt = parseInt(min); + const maxInt = parseInt(max); + if (minInt <= maxInt) { // Add the validator if min <= max - if ( - parseInt(min) > parseInt(this.value) || - parseInt(this.value) > parseInt(max) - ) { + if (minInt > valueInt || valueInt > maxInt) { // The value is out of range updateValidationArea( this.targetElement, @@ -850,7 +850,8 @@ function registerMinMaxValidator(e) { ) { // There is only 'min' available - if (parseInt(min) > parseInt(this.value)) { + const minInt = parseInt(min); + if (minInt > valueInt) { updateValidationArea( this.targetElement, `
This value should be larger than ${min}
`, @@ -868,7 +869,8 @@ function registerMinMaxValidator(e) { ) { // There is only 'max' available - if (parseInt(max) < parseInt(this.value)) { + const maxInt = parseInt(max); + if (maxInt < valueInt) { updateValidationArea( this.targetElement, `
This value should be less than ${max}
`,