1. By Hoàng Đăng Khánh
Client Side Validations
Framgia Study Seminar
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.
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
● …..
7. We need to add a validate: true option to the form_for
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