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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T23:40:05+00:00 2026-06-14T23:40:05+00:00

I am using jquery validation plugin for my form controls. I am easily able

  • 0

I am using jquery validation plugin for my form controls. I am easily able to validation three individual controls with three different messages with proper validation for number, minlength, maxlength. I have controls like web reference, date of birth, postcode and other fields, that have more than one textbox. Below is the html for web reference,

<input name="txtRef1" runat="server" type="text" id="txtRef1" />
<span class="ForwardSlash">-</span>
<input runat="server" name="txtRef2" type="text" id="txtRef2"  />
<span class="ForwardSlash">-</span>
<input runat="server" name="txtRef3" type="text" id="txtRef3"  />

I have written a custom validator method for this, which checks, if any of the above three textboxes are empty, then user will get one message – “Field is required”. I don’t want to have individual messages because it then breaks the design including forms design layout. The script to achieve the above is here:

function setuppagevalidationrecall() {

    $.validator.addMethod('example',

      function (value, element) {

              return ((value != "") && ($('#txtRef2').val() != "") && ($('#txtRef3').val() != ""));

          }, "Field is required");


    var validator = $("#form1").validate({
        rules: {
            txtRef1: {
                example: true,
                number: true,
                minlength: 3,
                maxlength: 3
            }

        }
    });

How can I improve this functionality to also check for number, minlength and maxlength so that for all the three textboxes above I get only one message as a
validation message. And also to make the example method dynamic like with arguments so that it can be applied for any field like postcodes (2 textboxes), date of birth (3 textboxes, dd/mm/yyyy)

  • 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-14T23:40:06+00:00Added an answer on June 14, 2026 at 11:40 pm

    Displaying a single validation message for multiple controls is what groups are for.

    Specify grouping of error messages. A group consists of an arbitrary group name as the key and a space
    separated list of element names as the value. Use errorPlacement to
    control where the group message is placed.

    use

    groups:{ txtRef : "txtRef1 txtRef2 txtRef3" }
    

    and

    errorPlacement: function (error, element) {
                    if (element.attr("name") == "txtRef1"
                 || element.attr("name") == "txtRef2"
                 || element.attr("name") == "txtRef3")
                        error.insertAfter("#txtRef3");
                    else
                        error.insertAfter(element);
        }, 
    

    Try it here:

    http://jsfiddle.net/uZYMr/2/

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

Sidebar

Related Questions

i using this JQuery Form Validation Plugin. https://github.com/posabsolute/jQuery-Validation-Engine I am able to attach it
I am using jquery validation plugin for form validation. I have added a custom
I'm try to validate form using jquery validation plugin my from code: source code
I'm using the Jquery Validation plugin to validate my form on the client before
I'm using a jquery validation plugin First I add the validation to the form:
I'm using the validation plugin of jQuery to check some values of my form.
I am creating a JavaScript / ajax comment form using the jQuery Validation Plugin.
I am using the jQuery validation plugin on my form. I set the basic
I have a form using jquery validation plugin. My submit button has an ajax
I'm using the jQuery Validation Plugin on my form. On my form I have

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.