[Input Masks] Discussion

[Input Masks] Discussion

  
Forge Component
(17)
Published on 2012-04-27 by António Chinita
17 votes
Published on 2012-04-27 by António Chinita
Hi António,

You don't have this for the 5.1 version? That would be great.

Thanks,
Hermínio
Hi Hermínio, I'll try and add that version over the weekend. :-)
Good work! António
There's a 5.1 compatible download avaliable in the version history. :)

I'd apreciate if someone could give feedback, as I haven't tested it properly.
The 5.1 version doesn't have a demo page, but the parameters have their descriptions and/or their names are self explanatory, so it should be fairly easy to test.

Best regards,
New Version
The previous versions were lacking a way to effectively force decimal/currency values.
Added a new function named CurrencyMask() to be used as input for the WebBlock, and that will force decimal/currency inputs with the specified options.


Future Version
Also, I would like to include in future versions a function to provide commonly used Masks out of the box.
Eg. Like the one provided in the example for the NIB: "9999-9999-9999-9999-9999 9"

So, if you use this component and you defined a mask you think might be useful to others, please feel free to share it here.
I will include it in the next version with propper credits :-)


Hi António

I have just tested the currency mask and works GREAT!!! but I found some issues, maybe u can help

  1. If we use the a group separator like ',' in the text box works fine but the variable is set to 0. (if the variable is text instead of decimal it works fine)

  2. The mask only run on text change it was great if it work on load

Thanks,
Bruno Santos
Hi Bruno.

Regarding your questions:
  1. This is not a specific problem of the WebBlock itself. Try using ',' while filling any element (without using the component) bound to a Decimal variable, and you'll get the same result. I'll try and fix this asap.
  2. Note taken, will be done in the next version (along with #1)
Thank you for your feedback, it really helps improving the component. I'll PM you when the update is done. :)

P.S. What I do to prevent users from using "," instead of "." is set an advanced property OnKeyUp for that Input with the code: this.value = this.value.replace(',','.');
This will always replace commas with dots, avoiding that pesky 0. :-)
- Uploaded a new version containing the bug fix that solves the onload issue with the currency mask

About using comma as decimal separator:
I've found a few ways to deal with it, but they seemed rather messy so I chose not to implement any of them to keep the code clean and simple.
If anyone has an idea of how to intercept data between the DOM and the Page Variables, in order to send a parsed value to the variables without changing the DOM value, it would help a lot with this matter.

For now, just avoid using comma as decimal separator on an input bound to a Decimal variable. The same goes for any GroupSeparator.
To use a Group Separator or a decimal separator other than the dot, you need to bind your input to a Text variable and then parse the result when saving data.
Bruno Santos wrote:
  1. If we use the a group separator like ',' in the text box works fine but the variable is set to 0. (if the variable is text instead of decimal it works fine)
 
 I'm pleased to say I just uploaded a new version that fully supports decimal and group separators. No more conflicts with the platform formats.
So now you can have masks like 1.000.000,00 without any type of conflict.

I added the feature to the CurrencyMasks being set by ControlId (not by class name, for compatibility reasons. Will handle it soon.)

Hope it helps :]
António Chinita wrote:
I'm pleased to say I just uploaded a new version that fully supports decimal and group separators. No more conflicts with the platform formats.
So now you can have masks like 1.000.000,00 without any type of conflict.
 
 Thanks António, now it works like a charme.

Just have a little bug in the javascript function mask() of the webblock 'MaskMoney' if the initial value has a decimal without the decimal part, for example 10 or 10.5 the value that appears in the textbox was 0.10 or 1.05

I fixed it by addind this code:

function mask() {
  var value = parseFloat(input.val());
  value = isNaN(value) ? 0 : value.toFixed(settings.precision);

  input.val(maskValue(value));
}


Thanks again
Bruno Santos
Bruno Santos wrote:
 
 Thanks António, now it works like a charme.

Just have a little bug in the javascript function mask() of the webblock 'MaskMoney' if the initial value has a decimal without the decimal part, for example 10 or 10.5 the value that appears in the textbox was 0.10 or 1.05

I fixed it by addind this code:

function mask() {
  var value = parseFloat(input.val());
  value = isNaN(value) ? 0 : value.toFixed(settings.precision);

  input.val(maskValue(value));
}


Thanks again
Bruno Santos
 
 Hi Bruno. Nice to know it helped. I had a fix for that here as well, just didn't test it enough to release.
Yours seems more complete than mine, so I'll just add yours! Thanks for sharing. :D
Hi Chinita,

I have done a integration with a similar Input Mask component. How do you solve the issue according to the onload "problem"?
Thanks.


Best reggards,
NM








I had the following problem with using the same mask NIB decimal field, whenever I try to bring me back the answer, Decimal expected, someone has gone through this and know how to solve?
Cleyton wrote:
I had the following problem with using the same mask NIB decimal field, whenever I try to bring me back the answer, Decimal expected, someone has gone through this and know how to solve?
 
 Hi Cleyton,

without looking to the component code, I'll try to guess what is probably happening. By using the mask the input text must probably have some non numeric chars and the variable that you are using to store that value is probably a Decimal var.

That beeing said, try to use a text var and let us know if this fixes this problem.

regards,
Miguel 
Thanks for responding!
It is true that this also occurs with integer field, see in the picture what actually happens! I've tried several options to solve the problem and nothing!
Because it is a mask, I thought the characters were ignored when submitting the field ...

The variable that step in this field is of type interger, decimal var
Hi,

at the moment I am getting this error:

An exception occurred in the client script. Error: f.data(a.mask.dataName) is not a function

Any clue what is wrong?

Hi Chinita. I had problem on the ipp process. Can you help? Do I have to purchase it?
How do I create a mask that validates from right to left. For example a field for UK postal codes where two of the characters on the left may be optional.
Hi Chinita,

I notice that after using input mask the on change stop working and doesn't call the function that it used to call.

Can you help?
Hi there,

Is there an easy way that i can use masks in expression (for ShowRecord)?

Also, is there a way for retrieve the value without the mask in it? I mean, i store the data without masks and to do that e need to use replace to remove all the mask special characters.

Thanks.

Regards,
Pedro Domingues
Hi,
I want to apply format currency in one of the text box.
The task is to convert currency into decimal in the textbox eg
if i give number 2454664 it has to convert into 24546.64 like this.
I assigned one action for this text box and i'm assigning like this 

FormatCurrency(GetBorrowerByClientId.List.Current.LoanDetail.AppraisedValue, Site.Currency, 2, Site.DecimalSeparator, Site.GroupSeparator)

but i'm getting the error saying the record is currecny data type.Please see my screenshot for reference.

Hi,

Please see my screenshot.This is the error i'm getting when applying the actions inside the
textbox.How do i solve this.
Hello Chandrasekar Radhakrishnan.
I think you should start a specific new discussion instead of just replying in this discussion.
FormatCurrency() receives a first parameter of type Currency and the value that you are passing, "ClientEdit.Record.LoanDetail", is of type Text.
You must supply a value of type Currency / Decimal.
Hi,
But i'm passing only as currecny for the "ClientEdit.Record.LoanDetail".
Hello,

Is it possible to mask a NIF or a phone number? on the demo there is a mask for phone numbers...

What settings should i use?
NIF: 999 999 999 (is it possible to format with spaces?)
phone number: (999) 999 999 999

Thanks,
Luis

Olá,
 
Estou precisando aplicar máscara para valores monetários com 2,3 e 4 casas decimais, assim, estou testando o componente Input Masks, ele até funciona, porém, ao aplicar um Ajax Refresh no input que está vinculado ao ou no container a formatação é perdida e valores estranhos são exibidos.
 
Gostaria de saber se alguém já passou por isso.


in English

Hello,
 
I need to apply mask to monetary values with 2,3 and 4 decimal places, so I'm testing the Input Masks component, it even works, but by applying an Ajax Refresh the input that is linked to or container formatting is lost and strange values are displayed.
 
I wonder if someone has been there.

 
is there a new version for 9.0.1 / JQuery 1.8?