Skip to content

jtadeulopes/inputs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Inputs

Add helpers to create text_field with masks.

Dependencies

Plugin jRails github.com/aaronchi/jrails/tree/master

script/plugin install git://github.com/aaronchi/jrails.git

Installation

script/plugin install git://github.com/jtadeulopes/inputs.git

Rake Tasks

Updates javascript files and remove unnecessary files.

rake inputs:update

Usage

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') %>

Use Formtastic?

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)

Usage

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 %>

Based on plugins:

JSMask by Ozéias Sant’ana

github.com/ozeias/js_mask/tree/master

meioMask by Fabio M. Costa

github.com/fabiomcosta/jquery-meiomask/tree/master

Copyright © 2009 Jésus Lopes, released under the MIT license

About

NO LONGER MAINTAINED - Add a very simple way, masks in form fields.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published