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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T17:52:48+00:00 2026-05-24T17:52:48+00:00

I am validating a form with the jQuery validation plugin (using the plugin is

  • 0

I am validating a form with the jQuery validation plugin (using the plugin is required, as I have other functionality that needs the plugin). It has the following fields:

phoneNumber
firstName
lastName
city
zip

The form is considered valid when one of the following statements is true:

  • phoneNumber is valid
  • firstName lastName city are all valid
  • firstName lastName zip are all valid

I know how to require each field and use the other validation methods (I even have my own for the zip), but I am trying to figure out an elegant solution to implement the logic I described above. Is a custom method or validation groups the best way to handle this?

  • 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-24T17:52:49+00:00Added an answer on May 24, 2026 at 5:52 pm

    Elegant is in the eye of the beholder…

    I would recommend making a custom validator to handle the three cases that you have.

    I spent a while to understand what Validate could do… I came up with this to validate my form. I used an async call to a servlet to do my username check… but you can put what ever you want in it.

    I found another post on stack overflow that greater illustrates making custom validators…
    I particularly like this line jQuery.validator.methods['date'].call(this,value,element) as it seems you can use the built in validators within your custom code. jQuery Validate Plugin – How to create a simple custom rule?

    These are the resources I used in learning about validate:
    http://www.ferdychristant.com/blog//articles/DOMM-7LZJN7 //article detailing how to really use validate.
    http://www.ferdychristant.com/blog//pages/jQuery%20validation%20code
    http://randomactsofcoding.blogspot.com/2008/10/starting-with-jquery-how-to-write.html
    http://docs.jquery.com/Plugins/Validation/Methods/required#dependency-expression

    There is also an amazing depth of information simply in http://docs.jquery.com/Plugins/Validation …you just gotta click through it all!

    below you will also see that you can put javascript right into the rules section.

    $(document).ready(function() {
    
    $("#EmailUserEditFormId").validate({
    
        debug: true, //this lets it hit firebug
        onkeyup:false, //keep the traffic down for my async call
    
        rules: {
    
            username: {
                required: (jQuery('input#username:disabled').length==1)?false:true, //example of JS in a rule
                usernameCheck: (jQuery('input#username:disabled').length==1)?false:true //example of a JS rule with a custom validator 
            }
        },
    
        messages: {
            username: {
                required: "Please enter a unique username.",
                usernameCheck: "Username is already in use. Choose another."
            }
        }
    
    });
    

    });

    …and this was my simple custom validator.

    jQuery.validator.addMethod('usernameCheck', function(username) {
    var postURL = "CheckUsername";
    $.ajax({
        cache: false,
        async: false,
        type: 'POST',
        data: 'username=' + username,
        datatype: 'xml',
        url: postURL,
        success: function(xml) {
            unique = (jQuery(xml).find('unique').text() == "true") ? true : false;
        }
    });
    return unique;
    

    }, ”);

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

Sidebar

Related Questions

I am using the jQuery Validation plugin and have an issue validating items that
I have a form with multiple fields that I'm validating (some with methods added
I am using the jQuery validation plugin on my form. I set the basic
I am using JQuery Validation plugin and have a question about validation. If I
I'm using the jQuery Validation plugin on my forms. I have some groups of
I am using jQuery validation plugin to validate my form, but it is seems
i using this JQuery Form Validation Plugin. https://github.com/posabsolute/jQuery-Validation-Engine I am able to attach it
I'm using form_remote_for() to do validation on a form's data so that my rails
I have a form containing a list of input fields that the user populates
Hi I am using jquery 1.4.2 and jquery validate 1.7( http://bassistance.de/jquery-plugins/jquery-plugin-validation/ ) Say 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.