Menu

How to make a mask to currency values?

2009-04-03
2013-04-22
  • Leonel Fonseca Ivo

    Hi there,

    I need to make a mask to currency values in the following way (Brazilian way of displaying currency values):

    - It can only accept numbers (obviously)
    - It has to be written from right to left
    - A ',' (comma) symbol have to be the separator of the integer and decimal parts
    - A dot ('.') have to separate each group of three numbers in the integer part

    I tried to use the fieldBuilder default construtor inside a InputMask to set accomplish some of the above points but I wasn't successful. I know that I can choose the direction of typing in a NumberMask, but I couldn't do any more than it. I would be grateful if you can help me.

    Thanks,

    Leonel

     
    • Luis Fernando Planella Gonzalez

      You should use a NumberMask for that.
      Look at http://javascriptools.sourceforge.net/samples/sample_mask.html

       
    • Leonel Fonseca Ivo

      Thanks man.

       
    • Leonel Fonseca Ivo

      Hey,

      Now I have another problem. I'm using the NumberMask to make the currency mask just like it is in the example. But it still accepting special characters, such like: ç, ~, ^, ', `, º, ª, etc.

      I was wondering if that's because these characters are made of a combination of keys of the keyboard and the javascript functions don't treat than right.

      Thanks in advance,

      Leonel

       
    • Leonel Fonseca Ivo

      The strange thing is that it only accepts some of the characters you obtain by pressing Shift + key. For example, it accepts the symbol '^' (which is obtained by pressing 'Shift'+'~' in my keyboard) but doesn't accept the symbol '{' (which is obtained by pressing 'Shift'+'['). Furthermore, try to input some symbols in the field results in showing '0,0', which is the case of the parenthesis and '*', for example.

      Additionally, it accepts every symbol you obtain pressing the 'Alt' key before.

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.