Created
July 18, 2011 18:56
-
-
Save rodrigopinto/1090325 to your computer and use it in GitHub Desktop.
Mais feio que encoxar a mãe no tanque...
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| FormFieldMask = { | |
| money: { | |
| event: 'keyup', | |
| regex: /[^\d,]/g, | |
| handler: function(event){ | |
| var field = event.target; | |
| field.setValue(field.value.replace(FormFieldMask.money.regex, '')); | |
| } | |
| }, | |
| integer: { | |
| event: 'keyup', | |
| regex: /[^\d]/g, | |
| handler: function(event){ | |
| var field = event.target; | |
| field.setValue(field.value.replace(FormFieldMask.integer.regex, '')); | |
| } | |
| }, | |
| // Magically applies the masks defined above | |
| apply: function(){ | |
| for (attr in FormFieldMask){ | |
| if (FormFieldMask.hasOwnProperty(attr) && attr != 'apply'){ | |
| eval("$j('."+attr+" input')."+FormFieldMask[attr].event+"(FormFieldMask."+attr+".handler);"); | |
| } | |
| } | |
| } | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment