diff --git a/client-side/netteForms.js b/client-side/netteForms.js index 17b6466a99..eef981baaf 100644 --- a/client-side/netteForms.js +++ b/client-side/netteForms.js @@ -311,6 +311,7 @@ Nette.validators = { }, 'float': function(elem, arg, val) { + val = val.replace(/ /g, ''); return (/^-?[0-9]*[.,]?[0-9]+$/).test(val); }, @@ -323,8 +324,9 @@ Nette.validators = { }, range: function(elem, arg, val) { + var floatVal = Nette.parseFloat(val); return Nette.isArray(arg) ? - ((arg[0] === null || parseFloat(val) >= arg[0]) && (arg[1] === null || parseFloat(val) <= arg[1])) : null; + ((arg[0] === null || floatVal >= arg[0]) && (arg[1] === null || floatVal <= arg[1])) : null; }, submitted: function(elem, arg, val) { @@ -443,6 +445,13 @@ Nette.parseJSON = function(s) { }; +Nette.parseFloat = function(val) { + val = val.replace(/ /g, ''); + val = val.replace(/,/g, '.'); + return parseFloat(val); +}; + + /** * Displays or hides HTML element. */