如何在用户键入Javascript时将数字格式化为货币

时间:2019-02-15 19:02:10

标签: javascript jquery html

我正在尝试将用户输入格式设置为货币。我有一个输入字段,用户可以在其中输入要支付的金额。当他们键入数字时,我希望它在键入时开始格式化。因此,明智地设置其格式为:

  

$ 1,200.23

1 个答案:

答案 0 :(得分:1)

您可以使用# Set our application environment SetEnv ENVIRONMENT beta SetEnvIf Origin "^http(s)?://(.+\.)?(somedomain.com|somedomain2.com)$" origin_is=$0 Header always set Access-Control-Allow-Origin %{origin_is}e env=origin_is Header set Access-Control-Allow-Credentials true <IfModule mod_rewrite.c> RewriteEngine on RewriteBase / RedirectMatch 404 ^/symfony/?$ RedirectMatch 404 ^/system/?$ RedirectMatch 404 ^/db/?$ RedirectMatch 404 ^/application/?$ RedirectMatch 404 ^/vendor/?$ RedirectMatch 404 ^/queue_workers/?$ RedirectMatch 404 ^/crons/?$ RedirectMatch 404 ^/[^/]\.(yml|json|lock)$ # Allow IP to Specific URL (TESTING - works until adding ! to REQUEST_URI) RewriteCond %{HTTP:X-FORWARDED-FOR} ^123\.123\.123\.123 RewriteCond %{REQUEST_URI} !\s/url[NC] RewriteRule ^ - [F] # End of the line -- static files & directories, or otherwise pass into CI frontend controller RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php?/$1 [L] </IfModule> 设置为Intl的{​​{1}} NumberFormat方法

currency
USD