Does anyone know a gem for ROR that does this job? Add masks to fields like phone, email, date, etc. and let me also create my own masks. Thank you.
Does anyone know a gem for ROR that does this job? Add masks to fields like phone, email, date, etc. and let me also create my own masks. Thank you.
I honestly do not believe there are any, since the masks must be done on the client side, and the gems usually act on the server side.
I use a gem , but it is nothing more than the jQuery loaded in the project, it works similar to bootstrap-rails
.
The mask library loaded in the system is jquery.inputmask .
I recommend gem Jquery :: Inputmask :: Rails for being very useful and well documented.
You can use htlm chews with the pattern parameter.
Example:
<%= ff.text_field :telefone_comercial, placeholder: '(DD)1234-5678', pattern: '\([0-9]{2}\)[0-9]{4,6}-?[0-9]{3,4}$' %>
The mask is made by regex. link In this link there are several patterns already written.