Skip to content
Advertisement

how to apply a mask to an item coming from an API with Javascript

I have a basic CRUD situation, where in the form, when I send the data, it inserts the mask normally, and when sending it to my local API, I format it and leave it in numeric format. But how am I going to apply the mask again on the item being displayed in a grid?

in my form, is like this

enter image description here

and on the grid, it displays like this

enter image description here

now, I need to apply the mask again, but on the grid that is showing. How to make?

to show the items on the grid, I am doing this via Javascript:

JavaScript

Advertisement

Answer

I understand that you are essentially looking for a way to turn a 14-digit string like “19879847984784” to “19.879.847/9847-84”.

You can add this JavaScript code to your script. The HTML is just an example with hard coded values.

JavaScript
JavaScript
JavaScript
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement