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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T11:20:06+00:00 2026-06-11T11:20:06+00:00

I have two select boxes that allows a user to select a valid day

  • 0

I have two select boxes that allows a user to select a valid day for example

<select name="valid">
    <option>monday</option>
    <option>tuesday</option>
    <option>wednesday</option>
    <option>thursday</option>
    <option>friday</option>
    <option>saturday</option>
    <option>sunday</option>
</select>

<select name="valid-2">
    <option>monday</option>
    <option>tuesday</option>
    <option>wednesday</option>
    <option>thursday</option>
    <option>friday</option>
    <option>saturday</option>
    <option>sunday</option>
</select>

what I need is a way to make sure if a user selects monday then they can not select monday or tuesday in the valid 2 select drop down.

However with out doing some thing like disabling the two days in valid two I am not sure how to do it.

I guess I could make the second select drop down after the user selects the first drop down.

So my question is how would you do it. and is there any simple and easy ways.

  • 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-11T11:20:08+00:00Added an answer on June 11, 2026 at 11:20 am

    Since we get to use jQuery, here’s my solution:

    $(function () {
        var $one = $("[name='valid']"), 
            $two = $("[name='valid-2']"), 
            $both = $($one).add($two),
            $error = $("#error");
    
        $both.on("change", function () {
            var index = $one.find(":selected").index(),
                index_two = $two.find(":selected").index();
    
            //Note: will also catch sunday/monday combo (that's why it's % 6)
            if((Math.abs(index_two - index) % 6) < 2) {
                //Show an error of some sort, like this:
                $both.css("border", "1px solid red");
                $error.text("Dates cannot be less than 2 days apart!");
            } else {
                //Hide the error message:
                $both.css("border", "");   
                $error.text("");
            }
        });
    });
    

    I tossed in an error <span> after the options, you can see it in my JSFiddle demo:

    http://jsfiddle.net/V7HMU/

    As others have said, some sort of onsubmit-based validation is probably called for. It’s a bit annoying to users to have to sort things out on the fly while the site is criticizing their every choice. But if you want to provide some helper text, this is a pretty easy way to do it.

    I should note that this could be more efficient if you assigned IDs to the <select> drop downs and also provided some easier way to gauge values (like giving them numeric values). But I didn’t want to mess with your HTML too much (aside from defaulting to a valid option).

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

Sidebar

Related Questions

I currently have a ajax script that dynamically builds two select boxes enabled with
So I have two multiple select boxes like this <select id=foo multiple=multiple> <option value=1>Option
I have a form with two select boxes that are used to move values
I have two select boxes with dates. See here the jsfiddle: http://jsfiddle.net/egrba/ The people
I have two identical select boxes (aside from their names, of course), and I
I have a table with three columns, and two cells contain select boxes with
I have two text-boxes which are used to select a From and a To
I have two drop down boxes in my program. When you select an item
I have a form with two text boxes, one select drop down and one
I have two select menus (#id1 and #id2) that, when validated as containing a

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.