[Input Masks] Decimal Separator ',' problem

[Input Masks] Decimal Separator ',' problem

  
Forge Component
(18)
Published on 2012-04-27 by António Chinita
18 votes
Published on 2012-04-27 by António Chinita
Antonio,
 
I had some problems using the input mask when decimal separator was ',' like it is in Brazil.
 
When the server sent to the html page the value '150' the mask showed the value '1,50', because of the two decimal numbers.
 
To solve the problem I add this javascript code before the plug-in apply the mask:
 
if('" + CurrencyMaskOptions.CurrencyMaskOptions.DecimalSeparator + "' == ',') {
    if(osjs('#" + InputId + "').val().indexOf('.') == -1){
        osjs('#" + InputId + "').val(osjs('#" + InputId + "').val() + '.00');
    } else {
        if(osjs('#" + InputId + "').val().substring(osjs('#" + InputId + "').val().indexOf('.') + 1).length < 2) {
            osjs('#" + InputId + "').val(osjs('#" + InputId + "').val() + '0')
        }
    } 
}      
 
 
This javascript adds '.00' when the value does not contain any decimal value.
 
I hope it helps someone else.
 
thanks.
Thanks for your input Victor. I never thought of that specific situation.
I'll implement a way to handle such situations as well as other fixes soon. :)

Thanks a lot.
Bump... :)
Could I just clarify where you added this?  I'm looking in the Mask webblock in the InputMask espace.   I'm adding a new script block in the IsCurrency If container.  Is that correct? 
Hi Steve,

That's correct. You have to add the script in the "true" condition.

I'll attach my eSpace for you.
Perfect that worked great, thanks very much Victor.