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

  • Home
  • SEARCH
  • 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 8187999
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T02:45:21+00:00 2026-06-07T02:45:21+00:00

I want to use the jQuery.validate() plugin to check that the user has chosen

  • 0

I want to use the jQuery.validate() plugin to check that the user has chosen an option from 3 dropdown lists – day, month and year for their DOB. I don’t need to validate the actual date, just as long as they choose something. I just want the one validation error message to be displayed to read “Please provide your date of birth”.

You can imagine what the markup looks like, but here it is anyway:

<div class="dropdown">
  <select id="day" class="styled" name="day">
    <option value="">--</option>
    <option value="1">1</option>
    <option value="2">2</option>
    <option value="3">3</option>
    <option value="4">4</option>
    [ etc... ]
  </select>
</div>
<div class="dropdown">
  <select id="month" class="styled" name="month">
    <option value="">--</option>
    <option value="1">1</option>
    <option value="2">2</option>
    <option value="3">3</option>
    <option value="4">4</option>
    [ etc... ]
  </select>
</div>
<div class="dropdown">
  <select id="year" class="styled" name="year">
    <option value="">--</option>
    <option value="1993">1993</option>
    <option value="1992">1992</option>
    <option value="1991">1991</option>
    <option value="1990">1990</option>
    [ etc... ]
  </select>
</div>
  • 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-07T02:45:22+00:00Added an answer on June 7, 2026 at 2:45 am

    Not strictly JQuery, but i did a function in JavaScript, which configures the form drop downs to suit the number of days for a given month/year combination, it expects the drop downs to have the first entry as a description

    <select name="reg_day" id="reg_day">
        <option>Day</option>
        <option value="1">1</option>
        <option value="2">2</option>
        <option value="3">3</option>
        <option value="4">4</option>
    </select> 
    <select name="reg_month" id="reg_month">
        <option>Month</option>
        <option value="1">January</option>
        <option value="2">February</option>
        <option value="3">March</option>
        <option value="4">April</option>
    </select> 
    <select name="reg_year" id="reg_year">
        <option>Year</option>
        <option value="2012">2012</option>
        <option value="2011">2011</option>
        <option value="2010">2010</option>
        <option value="2009">2009</option>
    </select> 
    

    The Function

        function calculateDays(){
        //get the day, month, year drop downs
        var dayBox   = document.getElementById('reg_day');
        var monthBox = document.getElementById('reg_month');
        var yearBox  = document.getElementById('reg_year');
        if(monthBox.value>0){
            if(yearBox.value<1800){
                var year = new Date().getFullYear();
            } else {
                var year = yearBox.value;
            }   
            var daysThisMonth = 32 - new Date(year, (monthBox.value-1), 32).getDate();
        } else {
            var daysThisMonth = 31;
        }
    
        //save the first one, and the selected index
        var dayBoxText = dayBox.options[0].text;
        var dayBoxSelected = dayBox.selectedIndex;
    
        //clear the drop down (days)
        for(var count = dayBox.options.length - 1; count >= 0; count--){
                dayBox.options[count] = null;
        }
    
        //create the first option (ie the bit that says Day, Month, Year)
        var theOption = new Option;
        theOption.text    = dayBoxText;
        dayBox.options[dayBox.options.length] = theOption;
    
        //populate the days drop down with the new lists
        for(var i = 1; i <= daysThisMonth; i++) {
            var theOption = new Option;
            theOption.text    = i;
            theOption.value   = i;
            dayBox.options[dayBox.options.length] = theOption;
        }
    
        //if the day selected is less than days use choose the last, if not choose the selected index
        if(dayBoxSelected<daysThisMonth){
            dayBox.selectedIndex = dayBoxSelected;
        } else {
            dayBox.selectedIndex = dayBox.options.length-1;
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I use jquery validate plugin to verify what user input into the field. At
I use bassistance jQuery validation plugin to validate my inputs. I want to add
I use the jQuery Validate plugin to validate a form, and I want a
I want to validate text-boxes in JQuery bit I want to use regex for
I want to use jQuery to pull information from my database when I click
I want to use jQuery tabs ( http://jsfiddle.net/43FcS/2/ ) inside a div that's created
I want to use jquery draggable/droppable to let the user select a group of
I want to use jQuery Validation Plugin with jQuery UI Tabs . How I
I'm new to jQuery but want to use this form validation plugin: http://bassistance.de/jquery-plugins/jquery-plugin-validation/ In
I want to use a jQuery/JavaScript function to validate the input of a textbox.

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.