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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T08:05:47+00:00 2026-05-29T08:05:47+00:00

I have a jquery to validate my drop down. if ‘yes’ on radio box

  • 0

I have a jquery to validate my drop down. if ‘yes’ on radio box i can select from dropdown. if ‘no’ on radio box dropdown is greyed out.

If a both radio boxes are ‘yes’ and value in both dropdowns are ‘please select’ and submit button is clicked, a validation error occurs and DOES NOT redirect to index.html.

If one radio box is at ‘yes’ & dropdown ‘please select’ and the other at ‘no’ with value ‘red’ from dropdown and submit button is clicked a validation error occors and redirect to index.html. Obviously this defeats the purpose of a validation.

I hope someone can help as its driving me mad.!

I have narrowed it down to this being the probem:

});      
       $("input:submit").click(function(){         
           var retVal = false;
           $.each([1, 2], function(i, val){
              retVal = (validate(val) || retVal);
           });
            return retVal;   
       });
  • 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-29T08:05:48+00:00Added an answer on May 29, 2026 at 8:05 am

    If I understand correctly, you have a validate() function (which you don’t show) which validates the specified item and returns true if OK or false if invalid. On submit you want to call validate() for several items, and if any of them return false return false to the submit (conversely, return true only if all the validations are true.

    The way your existing code sets retVal, once it becomes true it will stay true because any boolean result from validate() ORed with true will be true. Try this instead:

           $("input:submit").click(function(){         
               var retVal = true;
               $.each([1, 2], function(i, val){
                  retVal = validate(val) && retVal;
               });
                return retVal;   
           });
    

    This starts with a default return of true, and then changes it to false if validate(val) returns false. Using && instead of || then means that once retVal is false it will stay false. In my opinion it would be clearer to just get rid of the && altogether and say:

    if (!validate(val)) retVal = false;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

when i select a type from a drop down box the form fields are
How do i select elements that have my custom data attribute data-validate with jQuery
I'm trying to get the selected value from a drop down list via jQuery.
Background I have a payment page where the user can select from a list
I have the following code using jQuery Validate. $(#register).validate({ debug: true, errorClass:'error', validClass:'success', errorElement:'span',
I have done various tests and I have found that the jQuery validate function
I have jQuery to select all font elements that are children of the element
I have a form with jQuery.validate. It checks if typed email is correct using
I have a form and I'm using jQuery to validate that the have entered
I have a small script where I take in a value from a select

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.