• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Client side validations gem - KhanhHD
 

Client side validations gem - KhanhHD

on

  • 702 views

 

Statistics

Views

Total Views
702
Views on SlideShare
702
Embed Views
0

Actions

Likes
0
Downloads
2
Comments
0

0 Embeds 0

No embeds

Accessibility

Upload Details

Uploaded via as OpenOffice

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    Client side validations gem - KhanhHD Client side validations gem - KhanhHD Presentation Transcript

    • 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 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.
    • 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 fields ● Support custom validations ● Work with any ActiveModel::Validations based model ● Client side validation callbacks ● Support custom validations ● …..
    • II. Install gem 'client_side_validations' ● rails g client_side_validations:install → config/initializers/client_side_validations.rb
    • 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 →/public/javascripts/rails.validations.custom.js
    • Refer ● http://railscasts.com/episodes/263-client-side-validations?view= ● https://github.com/bcardarella/client_side_validations/
    • Thank for listening