Difference between revisions of "SsFormatCurrency"

From SmartWiki
Jump to: navigation, search
(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…')
 
Line 16: Line 16:
 
Will return: €5,000.00
 
Will return: €5,000.00
  
===Explanation===
+
==Requirements==
JavaScript JS files can be added to [[Browser Script]] custom fields or on template pages, sign-up pages etc. using the following syntax:
+
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>
 
  
  
 
[[Category:JavaScript]]
 
[[Category:JavaScript]]

Revision as of 04:53, 14 August 2012

To format a number as a currency using JavaScript you can use 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

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>