How to implement Custom Mask for text fields?

The recommended method of customizing your AppGini-generated application is through hooks. But sometimes you might need to add functionality not accessible through hooks. You can discuss this here.
Post Reply
User avatar
wemersonrv
Posts: 12
Joined: 2015-09-08 13:43

How to implement Custom Mask for text fields?

Post by wemersonrv » 2015-09-25 15:17

Hi, i need to make custom masks for dome fields, for brazilian documents, like:

1- CPF
- 11 sequentially numbers stored widhout mask, like: 11111111111
- The mask : ###.###.###-##
- Number masked: 111.111.111-11

2- CNPJ
- 14 sequentially numbers stored widhout mask, like: 11111111000111
- The mask : ##.###.###/####-##
- Number masked: 11.111.111/0001-11

3- Brazil Phone Number
- 14 sequentially numbers stored widhout mask, like: 11111111000111
- The mask : (##) ####-####
- Number masked: (64) 9285-7651

Notes
#1 - In some states, we have phones with a 5 digit prefix, then the mask turns on (##) #####-#### and i really don't know how to do these changes on appgini.

#2 - I am working with an existing database and the 3 types of fields (cpf, cnpj and phones) are text fields with 11, 14 and 11 chars respectively.

Can you help me?

udayvatturi
AppGini Super Hero
AppGini Super Hero
Posts: 85
Joined: 2014-06-14 03:08
Location: India
Contact:

Re: How to implement Custom Mask for text fields?

Post by udayvatturi » 2015-10-12 10:56

Use magic hooks.
(Tablename-dv.js) and put the following code in it.

$("#number").mask("9999.999.999-99 ");

Example: http://jsfiddle.net/ZYH9f/345/

Post Reply