luci-base: validation.js: fix integer and float type validation
authorJo-Philipp Wich <jo@mein.io>
Fri, 31 Jan 2020 16:26:39 +0000 (17:26 +0100)
committerJo-Philipp Wich <jo@mein.io>
Fri, 31 Jan 2020 16:28:05 +0000 (17:28 +0100)
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
(cherry picked from commit 187bef9f6ce1263da21f72e91f79192847273ba7)

modules/luci-base/htdocs/luci-static/resources/validation.js

index dbf30488c179b5fd269aff7c2b51db004e244ff6..0544e2f68005833d2ad0b31fabe961c535e1855f 100644 (file)
@@ -221,7 +221,7 @@ var ValidatorFactory = L.Class.extend({
 
        types: {
                integer: function() {
-                       return this.assert(this.factory.parseInteger(this.value) !== NaN, _('valid integer value'));
+                       return this.assert(!isNaN(this.factory.parseInteger(this.value)), _('valid integer value'));
                },
 
                uinteger: function() {
@@ -229,7 +229,7 @@ var ValidatorFactory = L.Class.extend({
                },
 
                float: function() {
-                       return this.assert(this.factory.parseDecimal(this.value) !== NaN, _('valid decimal value'));
+                       return this.assert(!isNaN(this.factory.parseDecimal(this.value)), _('valid decimal value'));
                },
 
                ufloat: function() {