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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T13:04:53+00:00 2026-05-13T13:04:53+00:00

jQuery Validation plugin is used to validate all form data: http://docs.jquery.com/Plugins/Validation Have 3 select

  • 0

jQuery Validation plugin is used to validate all form data: http://docs.jquery.com/Plugins/Validation

Have 3 select fields for birth date: day, month, year.

First: How i can make sure that user selects all 3 fields and ‘invalid’ icon is displayed only when one of all three fields is not selected. For example, now i have those 3 select fields, but when i select first and it’s ok, then plugin displays ‘ok’ icon even if other two select fields (month, year) are not selected.

Second: How i can validate those 3 select fields and make sure that the person, which birth date is selected in those 3 select fields, is older than 18 years?

<select name="DOBd" id="DOBd">
    <option value="">DD</option>
    // day options
</select>
<select name="DOBm" id="DOBm">
    <option value="">MM</option>
    // month options
</select>
<select name="DOBy" id="DOBy">
    <option value="">YYYY</option>
    // year options
</select>

Also i set up that ‘error’ icon is displayed not after each one of them, but after all of them:

groups:{
    date_of_birth:"DOBd DOBm DOBy"
},
errorPlacement:function(error,element){
    if (element.attr("name") == "DOBd" || element.attr("name") == "DOBm" || element.attr("name") == "DOBy")
        error.appendTo(element.parent("td").next("td"));
    else
        error.appendTo(element.parent("td").next("td"));
},
  • 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-13T13:04:53+00:00Added an answer on May 13, 2026 at 1:04 pm

    You can add custom methods using $.validator.addMethod

    Add two methods: one for checking for all 3 selections (FullDate) and one for checking age (Age).
    Since the 3 elements are grouped, I just put one method on one selector and the other on another selector.

    Also, your errorPlacement function has an if/else that does the exact same thing, which isn’t necessary.

    $(function() {
      // this function requires month day and year selections
      $.validator.addMethod("FullDate", function() {
        //if all values are selected
        if($("#DOBd").val() != "" && $("#DOBm").val() != "" && $("#DOBy").val() != "") {
          return true;
        } else {
          return false;
        }
      }, '<img src="/path/to/image.png" alt="Please select a day, month, and year" title="Please select a day, month, and year" />');
    
      // this function checks the selected date, returning true if older than 18 years
      $.validator.addMethod("Age", function() {
        //only compare date if all items have a value
        if($("#DOBd").val() != "" && $("#DOBm").val() != "" && $("#DOBy").val() != "") {
          //get selected date
          var DOB = new Date($("#DOBy").val(), $("#DOBm").val(), $("#DOBd").val());
          var eday = new Date(); //get today
          eday.setFullYear(eday.getFullYear() - 18); //set to eighteen years ago
          //if older than 18
          if(DOB < eday) {
            return true;
          } else {
            return false;
          }
        }
        return true;
      }, '<img src="/path/to/image.png" alt="Must be 18" title="Must be 18" />');
    
      $("form").validate({
        rules: {
          DOBd: "FullDate",
          DOBm: "Age"
        },
        groups:{
          date_of_birth:"DOBd DOBm DOBy"
        },
        errorPlacement:function(error,element){
          error.appendTo(element.parent("td").next("td"));
        }
      });    
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 357k
  • Answers 357k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer The other answers are correct. Here is some code you… May 14, 2026 at 9:40 am
  • Editorial Team
    Editorial Team added an answer you ruin the noConflict concept by reassigning the jquery to… May 14, 2026 at 9:40 am
  • Editorial Team
    Editorial Team added an answer If you get that particular error, you don't actually have… May 14, 2026 at 9:40 am

Related Questions

No related questions found

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.