In JavaScript function, I want to concatenate a numbers.
Text Box value format `1.234.567,89`
But I split the value using "," and access two array having value as
First Array = 1.234.567
Then I used replace function to replace (.) dot by nothing, to access simple integer : 1234567
Code Sample
var number = element.value;
var numberArray = number.split(',');
开发者_StackOverflow社区numberArray[0] = numberArray[0].replace(/./g,"");
alert('numberArray[0]:'+numberArray[0]+'::numberArray[1]:'+numberArray[1]);
But I am getting numberArray[0] as null. Suggest something !!!
Do this instead
numberArray[0] = numberArray[0].replace(/[.]/g,"");
. (dot) matches every character in regex, enclosing it in [] changes the meaning
精彩评论