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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T14:12:30+00:00 2026-05-26T14:12:30+00:00

I have two inputs (text fields) required by JQuery Plug-in : <input type=text name=first_name

  • 0

I have two inputs (text fields) required by JQuery Plug-in :

<input type="text" name="first_name" id="first_name" class="valid" />
&nbsp;<label class="error checked" generated="true" for="first_name">&nbsp;</label>
<input type="text" name="second_name" id="second_name" class="valid" />
&nbsp;<label class="error checked" generated="true" for="second_name">&nbsp;</label>

Those two are required by JQuery Plug-in

<script type="text/javascript">

jQuery.noConflict();

jQuery(document).ready(function() {

var validator = jQuery("#FormCmj").validate({
    rules: 
    {
        first_name: "required",
        second_name: "required",

    },
    messages: 
    {
        first_name: "Écrivez votre adresse postale s'il vous plait!",
        second_name: "Écrivez le nom de votre ville s'il vous plait!",          
    },      
                                        });
                        }
            );

How can I make : only one input is required in them two : If user write first name, second name is not required or if user write his second name, first name is not required.

Have a nice day

  • 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-26T14:12:31+00:00Added an answer on May 26, 2026 at 2:12 pm
    1. Add this to add a custom validation method:

      jQuery.validator.addMethod("eitherOne", function (value, element, param) {
          if (value !== "" || $(param.other).val() !== "") return true;
          return false;
      }
      
    2. And use this to validate:

      jQuery(document).ready(function () {
      
          var validator = jQuery("#FormCmj").validate({
              rules: {
                  first_name: {
                      eitherOne: {
                          other: "#second_name"
                      }
                  },
                  second_name: {
                      eitherOne: {
                          other: "#first_name"
                      }
                  }
              },
              messages: {
                  first_name: {
                      eitherOne: "Écrivez votre adresse postale s'il vous plait!"
                  },
                  second_name: {
                      eitherOne: "Écrivez votre adresse postale s'il vous plait!"
                  }
              },
          });
      });
      
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a form with two text_fields: <input type=text id=post_name name=post[name] /> <input type=text
I have two text input fields like so: <input type=text id=test1.../> <input type=text id=test2.../>
i have two questions. 1, i have a input <input name=fruit type=text /> i
basically I have two input fields, name and username. The idea is that the
How can i achieve this using jQuery. I have two text inputs on the
I have a form with two input fields and a display text div: <div
i have two text inputs like the following, i don't want to use <form>
I have two input text boxes which are decimal. The sum of the two
I have two input fields, and without changing their names (i.e., I have to
I hope I can explain this right I have two input fields that require

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.