Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6819299
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T21:17:24+00:00 2026-05-26T21:17:24+00:00

I have datepicker, but I could not find a way to validate if the

  • 0

I have datepicker, but I could not find a way to validate if the user’s entry is a date or not AND if it follows the required format (format: yyyy-mm-dd)

This is my datepicker:

$("input[name='date']").datepicker({ dateFormat: 'yy-mm-dd', changeMonth: true, changeYear: true, numberOfMonths: 3, showButtonPanel: true});

I looked on this solution, “How to validate datepicker to forbid/reject certain dates?“. It looks simple enough, but it only checks whether it’s a weekend. It does not checks it the user entered a date, a random number or a typo (1231….30-30-2011…30/30/2011…212-565-565…etc.).

Please fiddle with my fiddle: http://jsfiddle.net/MDa4A/

Additional info (11-10-2011):
(Try these jsFiddles and type 0-0-0 or 0/0/0)

I used your answers to come up with a solution. It works when I use the format “yy-mm-dd”: http://jsfiddle.net/LyEvQ/

BUT it is totally useless when I use a different format (Ej.: “mm/dd/yy”): http://jsfiddle.net/LyEvQ/1/

I need both to work. Can you please help

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T21:17:24+00:00Added an answer on May 26, 2026 at 9:17 pm

    Something like this should work:

    jQuery.validator.addMethod("customDateValidator",
        function(value, element) {
            try { jQuery.datepicker.parseDate("mm/dd/yyyy", value); return true; }
            catch(e) { 
                return false;
            }
        },
        "Please enter a valid date"
    );
    
    $("input[name='date']").rules("add", { customDateValidator:true });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am new, i apologize, i had searched but could not find an answer
I currently have the DatePicker in my project but there are problems due to
can't find solution to this issue. So i have datepicker input field, it works
I have a datepicker and it can not allow dates prior to today VIA
I have a datepicker on my site. When you select a date, it displays
Possible Duplicate: php/Mysql query with inserting date fails I have a datepicker code below:
Let's say I have a datePicker called foobar: <g:datePicker name=foobar value=${new Date()} precision=day />
I've been trying to get my own opinion about this issue but could not,
i have a script for a datepicker and it puts the date selected to
I have a custom user control DatePicker.cs. Inside of another piece of code I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.