Class PTNumberFormatter

Object
   |
   +--PTNumberFormatter

class PTNumberFormatter


Utility class for formatting numbers.

Usage:	
 	var nf = new PTNumberFormatter(23.234);
 	nf.setCurrency(true)
 	nf.setCurrencySymbol('¥');
 	return nf.formatValue();
 

Defined in PTUtil.js


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

INVALID

<final> String INVALID

VERSION

<static> <final> Object VERSION

Constructor Detail

PTNumberFormatter

PTNumberFormatter(num)

Method Detail

formatField

void formatField(field)

formatValue

String formatValue(num)

setCurrency

void setCurrency(isCurrency)

setCurrencySymbol

void setCurrencySymbol(symbol)

setCurrencySymbolBefore

void setCurrencySymbolBefore(showSymbolBefore)

setDecimalPlaces

void setDecimalPlaces(numDecimalPlaces)

setDecimalSeparator

void setDecimalSeparator(separator)

setGrouping

void setGrouping(showGroupingSeparator)

setGroupingSeparator

void setGroupingSeparator(separator)

setNegativePrefix

void setNegativePrefix(symbol)

setNegativeSuffix

void setNegativeSuffix(symbol)

setNumber

void setNumber(num)

toFormatted

String toFormatted(number)

toUnformatted

Number toUnformatted()

validateValue

Boolean validateValue(number)


Documentation generated by JSDoc on Wed Aug 24 10:17:38 2005