validation - Parsing numbers with a comma decimal separator in JavaScript -


i used function check if value number:

function isnumber(n) {     return !isnan(parsefloat(n)) && isfinite(n); } 

my program need work german values. use comma decimal separator instead of dot, function doesn't work.

i tried this:

n.replace(",",".") 

but doesn't seem work. exact function tried use is:

function isnumber(n) {     n=n.replace(",",".");     return !isnan(parsefloat(n)) && isfinite(n); } 

the number looks 9.000,28 instead of usual 9,000.28 if statement wasn't clear enough.

you need replace (remove) dots first in thousands separator, take care of decimal:

function isnumber(n) {     'use strict';     n = n.replace(/\./g, '').replace(',', '.');     return !isnan(parsefloat(n)) && isfinite(n); } 

Comments

Popular posts from this blog

python - Selenium remoteWebDriver (& SauceLabs) Firefox moseMoveTo action exception -

html - How to custom Bootstrap grid height? -

transpose - Maple isnt executing function but prints function term -