Text field mask without using jquery

Asked

Viewed 809 times

0

Does anyone know a ROR guide who can do this job? Add masks to fields like phone, email, date, etc and allow me to also create my own masks. Thank you.

2 answers

1

Honestly, I don’t believe there are any, because the masks should be made on the client side, and the Gems usually act on the server side. I use a Gem, but she is nothing more than the jQuery loaded in the project, works similar to the bootstrap-rails.

The mask library loaded into the system is the jquery.inputmask.

I recommend the Gem Jquery::Inputmask::Rails as well as being useful and well documented.

0

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. http://html5pattern.com/ In this link there are several patterns already written.

Browser other questions tagged

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