This document discusses client-side validation in web forms. It describes how client-side validation can catch errors before form submission, improving the user experience and application performance by reducing roundtrips to the server. It also outlines the features and installation of the ClientSideValidations gem, which automatically generates client-side validation rules from the server-side rules to provide validation on the client. Custom validators can also be defined to trigger validation logic when form fields lose focus.
1 of 10
Download to read offline
More Related Content
Client side validations gem - KhanhHD
1. By Hong 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