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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T10:45:21+00:00 2026-06-15T10:45:21+00:00

Edited, See below I have, for now, two radio buttons, each with a value

  • 0

Edited, See below

I have, for now, two radio buttons, each with a value representing the number of account holders. I.e.:

<INPUT id="ONE_HOLDER" name=NR_OF_HOLDERS value=1 type=radio />
<LABEL for=ONE_HOLDER>One holder</LABEL>
<br />
<INPUT id="TWO_HOLDERS" name=NR_OF_HOLDERS value=2 type=radio />
<LABEL for=TWO_HOLDERS>Two holders</LABEL>

I want to validate everytime one of the radio buttons is selected, so I use the Jquery validator to do the following:

//Validations fix for radio and checkbox checks
$('input[type="radio"],input[type="checkbox"]').change(function(){
    $("#YOUR_ACC").validate().element(this);
});

This calls

$('#YOUR_ACC').validate({ ... });

which in turn runs through my custom validator method which is the following:

$.validator.addMethod("numberOfHolders", function(value, element) {
    try {
        nrOfHolders = value;
        alert("The value is " + nrOfHolders);
        if(nrOfHolders == 1)     { return true; }
        else if(nrOfHolders == 2){ return false; }          
    }
    catch(err) {
        return false;
    }
});

It runs through it and all, but the problem is that when I select the first radio button, which is the one that needs to be selected it keeps that value(1) eventhough I select the second radio button.

Why is that and how do I fix it?

Edit for solution

See answer in repsonse below.

  • 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-15T10:45:22+00:00Added an answer on June 15, 2026 at 10:45 am

    My solution

    It seems like value in

    addMethod("numberOfHolders", function(value, element) { });
    

    Doesn’t take the value of a radio button.
    I made it work by getting the correct element using the element parameter (to be sure and more dynamic) and then get the value of the checked radio button like you would do in a regular jQuery method:

    var element_name = $(element).attr('name');
    value = $('input:radio[name="'+element_name +'"]:checked').val();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a dictionary (see below) that has Key strings and Value strings and
EDITED*** Thank you for the help below. I understand $(this).children() now and I have
EDITED: this first version was a false example with false assumptions! See below for
I Have Some static images like below: Now, I want is, when i touch
******QUESTION WAS EDITED, Please see below** I am running into a problem when I'm
EDITED with solution (below...) I have a Splash screen that is packaged into it's
I have edited this post with my question writen in a more simple way
I have two .php files which show all contacts in a database, then allows
I have setup a Visual Studio project that I have edited to reference the
((Answer selected - see Edit 5 below.)) I need to write a simple pink-noise

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.