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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T16:16:03+00:00 2026-05-20T16:16:03+00:00

Long time listener, first time caller… I’ve got two questions in a form, the

  • 0

Long time listener, first time caller…

I’ve got two questions in a form, the first of which is a ‘Yes’ or ‘No’ pair of radio buttons:

“Have you filed an application with us before? ( ) Yes ( ) No”

…the second of which is a text input allowing for a sloppy date value:

“If yes, when did you apply? [__________]”

You might already see where I’m going with this … I only want the second question to be required if “Yes” was chosen from among the radio buttons.

I’ve done a bunch of Google’ing, searching jQuery’s site (not fun or easy), and searching this very fine site, but the closest I’ve come to an answer always appears to make use of unique ID attributes on the radio inputs.

Sadly, I’m in a situation where the radio inputs can’t have ID attributes because they’re generated by a CMS. So, I’m left trying to use the unique name attribute on the pair of radio inputs, along with checking if the one with a value of Yes is ‘selected’/’checked’.

Here’s my HTML:

<li>
    <span class="reqField">*</span> Have you filed an application with us before?<br />
    <label class="radioInput"><input type="radio" name="app_prior_app" value="Yes" /> Yes</label>
    <label class="radioInput"><input type="radio" name="app_prior_app" value="No" /> No</label>
</li>
<li>
    <label for="app_prior_app_date">If <em>yes</em>, when did you apply?</label><br />
    <input type="text" name="app_prior_app_date" value="" size="40" id="app_prior_app_date" />
</li>

And here’s my JS so far:

app_prior_app: "required",
app_prior_app_date: {
    required: function(element) {
        return $("[name=app_prior_app]").val() == "Yes";
    }
}

Naturally this doesn’t work as desired. I know that if I could toss IDs on each radio input, this would be easier on me (I’m not too good with this stuff), but I’m assuming there’s a way to do this using just the unique name attribute and determining if the value “Yes” is the one selected, then (and only then) go ahead and require the text input?

  • 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-20T16:16:03+00:00Added an answer on May 20, 2026 at 4:16 pm

    A simple modification you can do to get what you need might look something like so:

    app_prior_app: "required",
    app_prior_app_date: {
        required: function() {
            return $("input[name=app_prior_app]:checked").val() === "Yes";
        }
    }
    

    Make sure you run app_prior_app_date.required() whenever the app_prior_app radio buttons are changed, though, so the script can maintain the correct state whatever a user does on the page.

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

Sidebar

Related Questions

Hey Overflow. Long time listener, first time caller. So here's what I've got: I'm
As they say on the radio - long time listener first time caller.... Here's
Long time listener, first time caller. I'm a full time SE during the day
Hey, long time listener first time caller, and I'm asking a question related to
long time listener. First time caller... Not strictly a PHP question as it involves
Long time listener, first time caller. Does anyone know of a good interop library
long-time listener, first-time caller! I’m trying to connect to MySQL using the ADO.NET Entity
Long time lurker, first time poster. I'm making a ServerConnection module to make it
Long time ago, the Game Developer magazine published an article about ID Software and
A long time ago I had an apple ][ . I remember the command

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.