How to create MASK with pure JS in React

Asked

Viewed 3,776 times

4

I am transforming a site HTML, CSS and jQuery in React but I saw that the use of jQuery is lagged in React since it is possible to create some components faster and simpler, my doubt is how to transform a Mask made in jQuery for pure Javascript, or better how to do this procedure more effectively in React ?

My Mask code is this:

/* Mask Contato */
$(document).ready(function(){
  $('.date').mask('11/11/1111');
  $('.time').mask('00:00:00');
  $('.date_time').mask('00/00/0000 00:00:00');
  $('.cep').mask('00000-000');
  $('.phone').mask('(00) 0 0000-0000');
  $('.phone_with_ddd').mask('(00) 0 0000-0000');
  $('.phone_us').mask('(000) 000-0000');
  $('.mixed').mask('AAA 000-S0S');
  $('.cpf').mask('000.000.000-00', {reverse: true});
  $('.valor').mask('000.000.000.000.000,00', {reverse: true});
});

1 answer

2


Take a look at this library: text-Mask, with her you can do masking in various ways.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.