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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T17:46:07+00:00 2026-06-05T17:46:07+00:00

I have a dropdown selector, with values from 1-4. Depending on the selection, subsequent

  • 0

I have a dropdown selector, with values from 1-4. Depending on the selection, subsequent inputs in form are hidden and validation required is removed from each.
eg, if 2 is selected, then inputs 1-2 are shown and validation required is added whilst 3-4 are hidden and validation removed.

$("#dropdownSelector").change(function() {
inputtohide = $(this).val();
$('input[id*=conviction]').slice(0, inputtohide).show().rules("add", {required: "#convictions_0:checked" });
$('input[id*=conviction]').slice(inputtohide, 4).hide().rules("remove", {required: "#convictions_0:checked" });
$("#thisform").validate();
});

This works fine, however ( as the documentation for the validation plugin states ) validation is only added for the first element returned.

I understand from other posts , that the following code should add validation to each input:-

$("#thisform").validate();
$("input[id*=conviction]").each(function() {
    $(this).rules("add", {required: "#convictions_0:checked" });

    });

My question is how do I combine the two bits of code ?
Any help greatly appreciated, thanks.

  • 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-05T17:46:08+00:00Added an answer on June 5, 2026 at 5:46 pm

    You simply need to use the .each() function on your .slice() result in order to iterate over all the elements it returns:

    $('input[id*=conviction]').slice(0, inputtohide).each(function(){
        $(this).show().rules("add", {required: "#convictions_0:checked" });
    });
    
    $('input[id*=conviction]').slice(inputtohide, 4).each(function(){
        $(this).hide().rules("remove", {required: "#convictions_0:checked" });
    });
    

    Hope this helps !

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

Sidebar

Related Questions

I have a dropdown menu that pulls in text from a database column. The
I have several DropDown controls on a Web Form which are filled using AJAX
I have a form in which I am using remote validation to check if
I have a dropdown selector in place and I need to change it so
I have a drop-down selector and need to load other parts of the form
I have a drop-down selector and form fields below. I need to be able
I have a drop-down selector and need to load other parts of the form
I have a drop-down selector and need to load other parts of the form
I have a JQGrid selector, where the key is a dropdown I've populated via
I have a form with multiple select dropdown menus that start with the id:

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.