digitalwise
asked on
Comma Formatted Javascript
I have some javascript that comma-formats number inputs. Works great unless the number is a negative, and then it is adding a commas between the - sign and the first number. My changes haven't made a difference. Any ideas what I need to add?
function formatNumber(num) {
num = rev(num);
num = num.replace(/(\d{3})/g, '$1,');
num = rev(num);
if(num.charAt(0) == ',') num = num.substr(1);
return num;
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.