Book Image

jQuery 2.0 Development Cookbook

By : Leon Revill
Book Image

jQuery 2.0 Development Cookbook

By: Leon Revill

Overview of this book

Table of Contents (17 chapters)
jQuery 2.0 Development Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Implementing live form validation


It can be very useful for the user to get real-time feedback regarding validation errors as they type in your web form. If you are performing client-side validation with JavaScript as well as server-side validation, this can be achieved easily as you do not need to send a request to the server every time the user types in an input—you can do it all within the client. Once again, it is very important that the same data undergoes additional validation on the server side. The server-side validation can then be fed back to the web form after the user has submitted the form.

Getting ready

This recipe will adapt the client-side validation that has been created as part of the last five recipes. Ensure that you have completed these recipes beforehand.

How to do it…

Provide real-time validation to users by performing the following steps:

  1. First, we need to move all of the class checks from the for loop into their own function so that they can be reused. Move all of the...