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

The Archive Base Latest Questions

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

I’m using jQuery.Validate to validate and submit my forms. On this specific page, the

  • 0

I’m using jQuery.Validate to validate and submit my forms.

On this specific page, the user can select from entering credit card information (6 fields) or entering a Purchase Order number (1 field).

The selection is made by Radio button.

<table cellpadding="0" cellspacing="0" align="center" bgcolor="#FFFFFF" width="100%">
  <tbody>
    <tr>
      <td rowspan="5" width="280" valign="top"><br /></td>
      <td width="440" colspan="2"><br />
        <strong>name</strong> (as it appears on card) *<br />
        <input type="text" name="cardName" maxlen="100" onchange="selectRadio(0)" value="" /></td>
    </tr>
    <tr>
      <td colspan="2" width="440"><strong>card type</strong> *<br />
        <select name="cardType" onchange="selectRadio(0)">
          <option value="MasterCard">MasterCard</option>
          <option value="VisaCard">Visa</option>
          <option value="AmExCard">American Express</option>
        </select></td>
    </tr>
    <tr>
      <td width="440" colspan="2"><strong>card number</strong> (no spaces) *<br />
        <input type="text" name="cardNumber" maxlen="25" onchange="selectRadio(0)" value="" /></td>
    </tr>
    <tr>
      <td width="440" colspan="2"><strong>card identification number</strong> (on back of credit card)<br />
        <input type="text" name="cardId" maxlen="6" onchange="selectRadio(0)" value="" /></td>
    </tr>
    <tr>
      <td colspan="2" width="440"><strong>expiration date</strong> *<br />
        <select name="ExpMon" onchange="selectRadio(0)">
          <option value="">&lt;month&gt;</option>
          <option value="1">01</option>
          <option value="2">02</option>
          <option value="3">03</option>
          <option value="4">04</option>
          <option value="5">05</option>
          <option value="6">06</option>
          <option value="7">07</option>
          <option value="8">08</option>
          <option value="9">09</option>
          <option value="10">10</option>
          <option value="11">11</option>
          <option value="12">12</option>
        </select>

        <select name="ExpYear">
          <option value="" onchange="selectRadio(0)">&lt;year&gt;</option>
          <option value="2012">2012</option>
          <option value="2013">2013</option>
          <option value="2014">2014</option>
          <option value="2015">2015</option>
          <option value="2016">2016</option>
        </select></td>
    </tr>
    <tr>
      <td width="280"> </td>
      <td colspan="2" width="440"><br /></td>
    </tr>
    <tr>
      <td><input type="radio" name="paymentMode" value="purchaseOrder" />
        pay using a purchase order number<br /></td>
      <td valign="top"><br />
        <br />
        <br />
        <strong>purchase order number</strong> *<br />
        <input type="text" name="PONumber" maxlen="40" onchange="selectRadio(1)" /></td>
    </tr>
  </tbody>
</table>

My validation code looks something like this:

<script type="text/javascript">
    $(document).ready(function(){
        $("#frmRegistration2").validate({
            debug: false,
            rules: {


            },
            messages: {

            },
            submitHandler: function(form) {
                // do other stuff for a valid form
                $.post(\'/beta4/_action.php\', $("#frmRegistration2").serialize(), function(data) {
                        $(\'.pane2\').slideUp(\'slow\');
                        $(\'#result2\').html(data);
                        $(\'.pane3\').slideDown(\'slow\');

                });
            }
        });
    });
    </script>';

Somebody suggested using the depends rule, however I am not sure how to use this .. The example given just checks to see if I radio button is checked. The problem is I have 2 radio buttons, not just one. So it has to depend on the VALUE of the radio button. Can someone show me how to do this?

Here is the example code:

$("#myForm").validate({
   rules: {
      contact: {
         required: {
            depends: function(element) {
               return $("#myCheckbox:checked");
            }
         }
      }
   }
})
  • 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:36:43+00:00Added an answer on June 11, 2026 at 11:36 am

    Well upon further study, this seems to work in the rules:

    rules: {
    PONumber: {
        required: {
            depends: function(element) 
                      {
                      return $("[name=paymentMode]:checked").val() == "purchaseOrder";
                      }             
                   }
               }            
           }
    

    The difficult part for me was that all the other examples ignored the fact that radio buttons should be used as selectors. ie, there are more than one radio button with the same name, but with different values. Using this method you can set your depend based on the value of the checked radio button. Works for me, it should work for you.

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

Sidebar

Related Questions

Does anyone know how can I replace this 2 symbol below from the string
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
That's pretty much it. I'm using Nokogiri to scrape a web page what has
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a jquery bug and I've been looking for hours now, I can't
I am reading a book about Javascript and jQuery and using one of the
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm making a simple page using Google Maps API 3. My first. One marker
link Im having trouble converting the html entites into html characters, (&# 8217;) i

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.