Add helpers to create text_field with masks.
Plugin jRails github.com/aaronchi/jrails/tree/master
script/plugin install git://github.com/aaronchi/jrails.git
script/plugin install git://github.com/jtadeulopes/inputs.git
Updates javascript files and remove unnecessary files.
rake inputs:update
Add in the head tag:
<%= javascript_include_tag :defaults %> <%= javascript_include_inputs %>
In form:
<%= masked_text_field(:user, :tel, :size => 13, :mask => '(99)9999-9999') %>
Other Examples:
Date: <%= masked_text_field(:user, :birth, :mask => '99/99/9999') %> CPF: <%= masked_text_field(:user, :cpf, :mask => '999.999.999-99') %>
A short description, taken from his README
"Formtastic is a Rails FormBuilder DSL (with some other goodies) to make it far easier to create beautiful,
semantically rich, syntactically awesome, readily stylable and wonderfully accessible HTML forms in your Rails applications."
More information on using the Formtastic, you can find here(en) or here(pt-br)
New option :mask was added, you can simply write:
<% semantic_form_for @product do |form| %> <%= form.input :price, :mask => :decimal %> <%= form.commit_button %> <% end %>
Automatically be added to field a mask Price.
You can use other masks, see:
-
phone
-
phone-us
-
cpf
-
cnpj
-
date
-
date-us
-
cep
-
time
-
cc
-
integer
-
decimal
-
decimal-us
-
signed-decimal-us
Or create your own type of mask, for example:
<% semantic_form_for @product do |form| %> <%= form.input :year, :mask => '9999' %> <%= form.commit_button %> <% end %>
- JSMask by Ozéias Sant’ana
- meioMask by Fabio M. Costa
Copyright © 2009 Jésus Lopes, released under the MIT license