Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
By Hoàng Đăng Khánh
Client Side Validations
Framgia Study Seminar
Using Client validation?
● Validation can occur as the form elements are completed and
before the form data is submitted t...
Client validation gem
● I. Features
● II. Install
● III. Usage
●I. Features
● Automatically extract and apply validation rules defined
on the server to the client.
● Validate nested fie...
II. Install
gem 'client_side_validations'
● rails g client_side_validations:install
→ config/initializers/client_side_vali...
initializers/client_side_validations.rb
We need to add a validate: true option to the form_for
Custom Validators
● /app/models/user.rb
→ validates :email, email_format: true
● when the email field loses the focus
→/pu...
Refer
● http://railscasts.com/episodes/263-client-side-validations?view=
● https://github.com/bcardarella/client_side_vali...
Thank for listening
Upcoming SlideShare
Loading in …5
×

Client side validations gem - KhanhHD

995 views

Published on

  • Be the first to comment

  • Be the first to like this

Client side validations gem - KhanhHD

  1. 1. By Hoàng Đăng Khánh Client Side Validations Framgia Study Seminar
  2. 2. Using Client validation? ● Validation can occur as the form elements are completed and before the form data is submitted to the server. ● Error recovery mechanism is quite simple as it guide the user while filling up the form and ensures the user has filled the required fields with valid data. ● A client-side input validation check can improve application performance by catching malformed input on the client and, therefore, saving a round-trip to the server.
  3. 3. Client validation gem ● I. Features ● II. Install ● III. Usage
  4. 4. ●I. Features ● Automatically extract and apply validation rules defined on the server to the client. ● Validate nested fields ● Support custom validations ● Work with any ActiveModel::Validations based model ● Client side validation callbacks ● Support custom validations ● …..
  5. 5. II. Install gem 'client_side_validations' ● rails g client_side_validations:install → config/initializers/client_side_validations.rb
  6. 6. initializers/client_side_validations.rb
  7. 7. We need to add a validate: true option to the form_for
  8. 8. Custom Validators ● /app/models/user.rb → validates :email, email_format: true ● when the email field loses the focus →/public/javascripts/rails.validations.custom.js
  9. 9. Refer ● http://railscasts.com/episodes/263-client-side-validations?view= ● https://github.com/bcardarella/client_side_validations/
  10. 10. Thank for listening

×