Jquery Validate Plugin : Custom date format validation (mm/dd/yyyy)

Suppose, you are using Jquery Validator plugin to validate form fields and now you want to validate date field with custom format like mm/dd/yyyy or dd/mm/yyyy then there is no way to do by passing parameters.

Currently, Jquery Validator plugin is not allowing to define date format for validation.

In this case, you need to add one custom function and you need to write date format validation code in it and need to pass that function as parameter for that field in validate rule function.

See Example below :

jQuery.validator.addMethod(
        "trioDate",
        function(value, element) {
            return value.match(/^(0[1-9]|1[012])[/|-](0[1-9]|[12][0-9]|3[01])[/|-](19dd|2ddd)$/);
        },
        "Please enter a date in the format mm/dd/yyyy"
    );
///////
$("#yourform").validate({
            rules: {
                dob: {
                    required : true,
                    date:true,
                    trioDate:true
                },
            }
}}

You can change regular expression according to your requirement.

VN:F [1.9.22_1171]
Rating: 5.0/5 (3 votes cast)
Jquery Validate Plugin : Custom date format validation (mm/dd/yyyy), 5.0 out of 5 based on 3 ratings

Get update with latest tech news.
Enter your email address:

About Chetan Patel

Chetan Patel is blogger, writes on Tech News, current trends, Gadgets Reviews, Website owner guide and Tips. You can connect him at Google+ & Facebook.
This entry was posted in Jquery. Bookmark the permalink.
  • Kalyani

    I need detail clarification about the JQuery and how to validate the date format using JQuery.

    VA:F [1.9.22_1171]
    Rating: +1 (from 1 vote)
  • swetha

    hieee..Need description about JQuery

    VA:F [1.9.22_1171]
    Rating: 0 (from 0 votes)
  • Kalyani

    need to know about Entity framework and how wite the queries in Entity framework and in LINQ to SQL

    VA:F [1.9.22_1171]
    Rating: 0 (from 0 votes)
  • Evuri Sundara Rami Reddy

    http://api.jquery.com/jQuery/

    VA:F [1.9.22_1171]
    Rating: 0 (from 0 votes)
  • Evuri Sundara Rami Reddy

    jQuery is a lightweight, “write less, do more”, library.

    The purpose of jQuery is to make it much easier to use on your website.

    jQuery takes a lot of common tasks that requires many lines of code to accomplish, and wraps it into methods that you can call with a single line of code.

    jQuery also simplifies a lot of the complicated things from , like AJAX calls and DOM manipulation.

    The jQuery library contains the following features:

    HTML/DOM manipulation
    CSS manipulation
    HTML event methods
    Effects and animations
    AJAX
    Utilities

    VA:F [1.9.22_1171]
    Rating: 0 (from 0 votes)
  • Evuri Sundara Rami Reddy

    hi this Reddy ,
    LINQ can be classified into 4 types :
    1.LINQ to object
    2.LINQ to sql
    3.LINQ to xml
    4.LINQ to entity [ADO.net Entity Framework]

    Deferred execution in LINQ is a way through which the queries can be executed at a later stage. In such an approach, an object is first defined that contains the query. This query runs only at a later stage. For example:

    var result = from reportcard in dbContext.Class5 where reportcard.studentname = ‘Pedro'; //This object result will execute later when used inside a foreach loop.

    Here, the query expression only defines the query. The object ‘result’ returns the actual result. During processing, Entity Framework lets the database do the actual processing by using the database routines. This makes it sure that the performance is at its best. Further, you may even create chained queries in LINQ where a query can query from another query. It is something like a nested statement.

    VA:F [1.9.22_1171]
    Rating: 0 (from 0 votes)
  • Evuri Sundara Rami Reddy

    I hope this information may be useful for you ………
    if you any queries let me know

    VA:F [1.9.22_1171]
    Rating: 0 (from 0 votes)
  • v

    super

    VA:F [1.9.22_1171]
    Rating: 0 (from 0 votes)