How to convert this 20,00 into 2000 in javascript ?
Basically how to remove decimal sign but keep all digits?
How to convert this 20,00 into 2000 in javascript ? Basically how to remove
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Everybody stand back, I know regular expressions!
In other words, replace() all occurences of
,with an empty string. You could even use a character class to remove anything except digits, if that’s your intention:That may be useful as the decimal delimiter is locale-specific (which e.g. means that in English (
en_US), “two and a half” is “2.5”, whereas in Czech (cs_CZ) it’s “2,5”). Although JS always uses the decimal point for numbers, user-entered data will depend on the locale (e.g. the key next to 0 on numpad emits a,in some layouts), which can lead to confusion if your script expects a decimal comma and gets a decimal point instead.