Difference between revisions of "SsFormatCurrency"
From SmartWiki
(Created page with 'To format a number as a currency using JavaScript you can use function called ssFormatCurrency. ==Syntax== :<font size="3">'''ssFormatCurrency( ''number'', ''symbol'' );''' </f…') |
m (→Example: - extra example) |
||
(11 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
− | To format a number as a currency using JavaScript you can use function called ssFormatCurrency. | + | {{JavaScript Syntax}} |
− | + | ==Overview== | |
+ | To format a number as a currency using [[JavaScript]] you can use a function called ssFormatCurrency. | ||
==Syntax== | ==Syntax== | ||
Line 8: | Line 9: | ||
<b><em>number </em></b>- is a number to be converted to a currency (i.e: 5000)<br /> | <b><em>number </em></b>- is a number to be converted to a currency (i.e: 5000)<br /> | ||
<b><em>symbol </em></b>- is a currency symbol you want to use, i.e. "€", "$", "£", ... | <b><em>symbol </em></b>- is a currency symbol you want to use, i.e. "€", "$", "£", ... | ||
+ | |||
==Example== | ==Example== | ||
<pre> | <pre> | ||
− | ssFormatCurrency(5000,"€"); | + | ssFormatCurrency(5000, "€"); |
</pre> | </pre> | ||
Will return: €5,000.00 | Will return: €5,000.00 | ||
− | == | + | <pre> |
− | + | ssFormatCurrency(5000, " "); | |
+ | </pre> | ||
+ | |||
+ | Will return: 5,000.00 | ||
+ | |||
+ | ==Requirements== | ||
+ | This function is part of <b>validate.js</b> library and needs to be added to [[Browser Script]] custom fields or on template pages, sign-up pages etc. using the following syntax: | ||
<SCRIPT type="text/javascript" language="javascript" src="/validate.js"></SCRIPT> | <SCRIPT type="text/javascript" language="javascript" src="/validate.js"></SCRIPT> | ||
+ | ==See Also== | ||
+ | * [[SsParseNum]] | ||
[[Category:JavaScript]] | [[Category:JavaScript]] | ||
+ | [[Category:validate.js]] | ||
+ | [[Category:Currency]] | ||
+ | [[Category:Validation]] |
Latest revision as of 11:11, 30 July 2014
This feature uses JavaScript syntax |
Contents
Overview
To format a number as a currency using JavaScript you can use a function called ssFormatCurrency.
Syntax
- ssFormatCurrency( number, symbol );
Where:
number - is a number to be converted to a currency (i.e: 5000)
symbol - is a currency symbol you want to use, i.e. "€", "$", "£", ...
Example
ssFormatCurrency(5000, "€");
Will return: €5,000.00
ssFormatCurrency(5000, " ");
Will return: 5,000.00
Requirements
This function is part of validate.js library and needs to be added to Browser Script custom fields or on template pages, sign-up pages etc. using the following syntax:
<SCRIPT type="text/javascript" language="javascript" src="/validate.js"></SCRIPT>