| 
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
Object | +--PTNumberFormatter
   
Utility class for formatting numbers.
 
Usage:	
 	var nf = new PTNumberFormatter(23.234);
 	nf.setCurrency(true)
 	nf.setCurrencySymbol('¥');
 	return nf.formatValue();
 
  
| Field Summary | |
    <final> String | 
   INVALID
   Constant representing an invalid number  | 
   
   <static>  <final> Object | 
   VERSION
    | 
   
| Constructor Summary | |
      
	 
	    PTNumberFormatter 
	 
	 (num)
      
      PTNumberFormatter Object constructor  | 
|
| Method Summary | |
	 
	     void
	 
       | 
      
	 
	    
	       formatField(field)
	 
	 Convenience method which can be attached to the onBlur handler of a form field to validate and format the field's value  | 
   
	 
	     String
	 
       | 
      
	 
	    
	       formatValue(num)
	 
	 Returns the number formatted according to the settings (a string)  | 
   
	 
	     void
	 
       | 
      
	 
	    
	       setCurrency(isCurrency)
	 
	 Sets whether or not to display the number as currency  | 
   
	 
	     void
	 
       | 
      
	 
	    
	       setCurrencySymbol(symbol)
	 
	 Sets the currency symbol  | 
   
	 
	     void
	 
       | 
      
	 
	    
	       setCurrencySymbolBefore(showSymbolBefore)
	 
	 Sets whether or not the currency symbol appears before the number  | 
   
	 
	     void
	 
       | 
      
	 
	    
	       setDecimalPlaces(numDecimalPlaces)
	 
	 Sets the precision of decimal places  | 
   
	 
	     void
	 
       | 
      
	 
	    
	       setDecimalSeparator(separator)
	 
	 Sets the symbol that separates decimals  | 
   
	 
	     void
	 
       | 
      
	 
	    
	       setGrouping(showGroupingSeparator)
	 
	 Sets whether or not to display the grouping separator  | 
   
	 
	     void
	 
       | 
      
	 
	    
	       setGroupingSeparator(separator)
	 
	 Sets the symbol that separates groupings  | 
   
	 
	     void
	 
       | 
      
	 
	    
	       setNegativePrefix(symbol)
	 
	 Sets the prefix symbol for negative numbers  | 
   
	 
	     void
	 
       | 
      
	 
	    
	       setNegativeSuffix(symbol)
	 
	 Sets the suffix symbol for negative numbers  | 
   
	 
	     void
	 
       | 
      
	 
	    
	       setNumber(num)
	 
	 Sets the number used by the formatter  | 
   
	 
	     String
	 
       | 
      
	 
	    
	       toFormatted(number)
	 
	 Formats a given number.  | 
   
	 
	     Number
	 
       | 
      
	 
	    
	       toUnformatted()
	 
	 Returns the number in its native unformatted form  | 
   
	 
	     Boolean
	 
       | 
      
	 
	    
	       validateValue(number)
	 
	 Validates a number  | 
   
| Field Detail | 
<final> String INVALID
<static> <final> Object VERSION
| Constructor Detail | 
PTNumberFormatter(num)
num -  The number to be formatted (number)  
     | Method Detail | 
void formatField(field)
field -  The form field to validate (INPUT type="text" element or TEXTAREA element)    
      String formatValue(num)
num -  Number to set before formatting, optional.  (number)  
      void setCurrency(isCurrency)
isCurrency -  Whether or not to display the number as currency (boolean)    
      void setCurrencySymbol(symbol)
symbol -  The currency symbol to set (string)    
      void setCurrencySymbolBefore(showSymbolBefore)
showSymbolBefore -  Whether or not the currency symbol appears before the number (boolean)    
      void setDecimalPlaces(numDecimalPlaces)
numDecimalPlaces -  The number of decimal places. Any number of places less than or equal to zero is considered zero. (integer)    
      void setDecimalSeparator(separator)
separator -  Decimal separator symbol (string)    
      void setGrouping(showGroupingSeparator)
showGroupingSeparator -  Whether or not to display the grouping separator (boolean)    
      void setGroupingSeparator(separator)
separator -  Decimal separator symbol (string)    
      void setNegativePrefix(symbol)
symbol -  Negative prefix symbol. Default is '-'. (string)    
      void setNegativeSuffix(symbol)
symbol -  Negative suffix symbol. Default is ''. (string)    
      void setNumber(num)
num -  The number to be formatted (number)    
      String toFormatted(number)
number -  The number to format (number)  
      Number toUnformatted()
Boolean validateValue(number)
number -  The number to validate  
      
  | 
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||