项目作者: abhikanojia

项目描述 :
Allow Numeric - A numeric field validation Gem.
高级语言: Ruby
项目地址: git://github.com/abhikanojia/allow_numeric.git
创建时间: 2018-03-28T10:47:49Z
项目社区:https://github.com/abhikanojia/allow_numeric

开源协议:MIT License

下载


AllowNumeric

This gem provides easy way to restrict numeric input to input fields using jquery and integrates with Rails asset pipeline for easy of use.

Installation

Add this line to your application’s Gemfile:

  1. gem 'allow_numeric'

And then execute:

  1. $ bundle

Or install it yourself as:

  1. $ gem install allow_numeric

Usage

Add following line to “app/assets/javascripts/application.js”

  1. //= require allow_numeric

and restart rails server.

Add data-numeric="true" to field for which you want to allow numeric input only.

For example:

  1. <%= form_for @person do |f| %>
  2. ..
  3. ..
  4. <%= f.label :phone %>:
  5. <%= f.text_field :phone, data: { numeric: true } %><br />
  6. <%= f.submit %>
  7. <% end %>

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/abhikanojia/allow_numeric.

License

The gem is available as open source under the terms of the MIT License.

Code of Conduct

Everyone interacting in the AllowNumeric project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.