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

Adding date validation


Dates are common items of data, and it is important that the user be able to easily input a date into your web form. Typically, you would use a date picker that has date validation included to provide an easy input method. This recipe shows you how to manually validate a date in the UK format (that is, DD/MM/YYYY). Date pickers are covered in Chapter 9, jQuery UI, using the popular jQuery UI framework. Refer to the See also section of this recipe for more information.

Getting ready

Continuing the trend of the previous recipes of this chapter, ensure that you have validation.js open and ready for modification and that you have completed the previous three recipes.

How to do it…

Add date validation to your web form by performing the following simple steps:

  1. Update validation.js to add the additional date validation function and class check within the main for loop, shown as follows:

    $(function(){
       $('.submit-btn').click(function(event){
          
    // -- JavaScript from previous...