This is wrapper for jQuery plugin jquery-maskmoney.
Tested very quickly on Firefox 4 and Google Chrome on Windows 7
Extract the zip file to your extensions folder.
These are the variables you can change:
element: (required) the input field to be moneymasked (uses jQuery selector)
currency: (optional) used to set the symbol if config['symbol'] is not given
config: (optional) options for this extension.
The options that you can set are
symbol the symbol to be used before of the user values. default: 'US$'
showSymbol - set if the symbol must be displayed or not. default: false
symbolStay - set if the symbol will stay in the field after the user exists the field. default: false
thousands - the thousands separator. default: ','
decimal - the decimal separator. default: '.'
precision - how many decimal places are allowed. default: 2
defaultZero - when the user enters the field, it sets a default mask using zero. default: true
allowZero - use this setting to prevent users from inputing zero. default: false
allowNegative - use this setting to prevent users from inputing negative values. default: false
Use it like this:
$this->widget('application.extensions.moneymask.MMask',array( 'element'=>'#testing', 'currency'=>'PHP', 'config'=>array( 'showSymbol'=>true, 'symbolStay'=>true, ) )); echo CHtml::textField('testing', '', array('id'=>'testing'));
Bugs bugs bugs
I noticed just now that it is not masking the text field if it already has a value. There's still a need to type something for it be masked...
wonderful.. thx for a great extension
Thank you for this extension. I'm using this effectively...
may I ask you to make another handphone masking?.. like the script on this page
i just dont know how to modify from your moneymask to handphonemask... thank you, once again..
More than one moneymask
When I use more than one moneymask in my view page, only one field works.
More than one...
@banamlehsb yeh I had the same problem until I did the following:
1) only include one widget
2) in the 'selector' option, specify both (or as many) text inputs as you like in the normal $ way. (e.g. '#input1, #input 2')
More than one moneymask (solved)
@natb19: Thanks very much. I solved my problem. In 'element' option (not 'selector' option), I added selector jquery like you.
Note: In other text field you should change id of textfield exactly.
More than one...
Ahh, yes, element! show's how good my memory is! ;)
BTW, you don't have to use #id, your could use the same class name for all of the inputs you want to affect. That could make things easier when creating multiple forms... e.g.
and use different widget configs to affect them.
MoneyMask isn't masking when it already has value
Like @macinville comment. MoneyMask isn't masking when the text field already has a value.
When that field validated failed, you must type something on that text field to mask again.
Why after using the moneymask, the core CMaskedTextField stops working on the same form?
Didn't find solution on the forums...
Is there an option to unmask?
Bug with CMaskedTextField
I solved this problem changing jquery.maskMoney.js in assets folder. Both (CMaskedTextField and mask money) declare a function with same name (mask), I changed this name in maskMoney (and where it's called ) to solve the problem.
If you have any questions, please ask in the forum instead.
Signup or Login in order to comment.