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 7772337
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T16:51:58+00:00 2026-06-01T16:51:58+00:00

I have three fields for date input – day, month, year. Once it is

  • 0

I have three fields for date input – day, month, year.
Once it is input, I should verify it. The following code is used:

$('#test').click(function(event) {
    var daySelector = "#dd",
        monthSelector = "#mm",
        yearSelector = "#yyyy";
    var day = $(daySelector).val() == "" ? 1 : parseInt($(daySelector).val(), 10);
    var month = $(monthSelector).val() == "" ? 1 : parseInt($(monthSelector).val(), 10);
    var year = parseInt($(yearSelector).val(), 10);
    var date = new Date(year, month, day);
    var result = !isNaN(date.getTime());    
});

But it accepts (i.e. returns true) wrong values like 33/55/2000. Where is my mistake?
Demo

I’ve tried another approach – it doesn’t work well also.

  • 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-06-01T16:51:59+00:00Added an answer on June 1, 2026 at 4:51 pm

    Date object automaticly converts overflows.

    So if you create 32.01.2000 and there are only 31 days in the january then it will create object with
    01.02.2000 Date

    You have to change your validation logic from “Is Nan” to something more sophisticated;)

    One thing to note 🙂

    date.getMonth() returns 0-11 -> 0 equals january 😛 That was the source of my initial mistake in the answer.
    And it seems like you have to decrement value sent to the Date constructor.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following problem: I have a form with three text input fields,
Hi i have a table with the following fields 'Site Code' 'Date' 'Hour' 'Quantity'
I have a problem. I have 3 text field for day, month, year to
I have three fields, namely Number1 Number2 Time I am trying to write a
I have three text fields: first name, last name, and age, also a photo.
I have a table with three fields, FirstName, LastName and Email. Here's some dummy
I have a table with three fields, User , City and Country , where
I have created a UserForm where the user is required to fill-in three fields.
I have a program that uses three JTextField fields as the main data entry
I have a UITableViewController and UITableViewCell . This cell contains three text fields. Each

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.