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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T07:03:43+00:00 2026-05-17T07:03:43+00:00

I am using Jquery valdiation plugin for validating the form at client side. I

  • 0

I am using Jquery valdiation plugin for validating the form at client side.
I am fetching validation error messages from an xml file.

$("#"+form).validate({
    errorLabelContainer: "#dialogError", //msg_error
    wrapper: "li",
    rules: {
        txtInfringementID: {
            required: true,
            digits: true
        },
        txtLicenceNumber: {
            required: true            
        },
        txtDateOfOffence: {
            date: true,
            required: true
        }
    },
    messages: {
        txtInfringementID: {
            required:this.errorMessage("InfringementID","Required"),
            digits: "Inf Id must be numeric only"
        },
        txtDateOfOffence: {
            required: "please enter date of offence",
            date: "Date is not valid"
        },
        txtLicenceNumber:this.errorMessage("LicenceNumber", "Required"),
        txtSurname: this.errorMessage("DebtorSurname", "Required")
    }
)};

errorMessage function is below.

this.errorMessage = function (Field, Rule) {

    var message;
    $.ajax({
        type: "GET",
        url: "../../../ErrorMessages.xml",
        dataType: "xml",
        success: function (xml) {

            $(xml).find("*[Name='" + Field + "']").each(function () {
                message = $(this).find(Rule).text();
            });
        }
    });

    return message; **//I am using a debugger here**
}

and the xml I am using is

<?xml version="1.0" encoding="utf-8" ?>
<ErrorMessage>
    <Field Name="InfringementID">
        <Required>Infringement ID is required</Required>
        <Digit>Infringement ID should be numeric only</Digit>
    </Field>
    <Field Name="LicenceNumber">
        <Required>License Number is Mandatory</Required>
    </Field>
    <Field Name="DebtorSurname">
        <Required>Debtor Surname is Mandatory</Required>
    </Field>
</ErrorMessage>

But the problem is that when I use debugger, I am getting messages from xml. If I don’t use debugger, I am getting default message ‘this field is required’. I think, the issue is this.errorMessage() is a asynchrounous request and this request is taking some time to complete. I tried to put some delay using setTimeout function. but I don’t know where to put the time delay. Any thought process is welcomed.

I am setting timeout like this.

required:setTimeout(this.errorMessage("InfringementID","Required"),10000),
  • 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-17T07:03:46+00:00Added an answer on May 17, 2026 at 7:03 am

    errorMessage starts the ajax-call and returns directly after that without waiting for the response. Because of that message will be null all the time.
    Your approach with setTimeout only delays the call of errorMessage. The result will be the same as without it.
    Make your ajax-call synchronous and thereby wait for the result of it.

    $.ajax({
        type: "GET",
        async: false,     // wait for the response
        url: "../../../ErrorMessages.xml",
        dataType: "xml",
        success: function (xml) {
            $(xml).find("*[Name='" + Field + "']").each(function () {
                message = $(this).find(Rule).text();
            });
        }
    });
    

    Edit
    I don’t exactly know what you are asking for, but I will give it a try…
    Because of the last line of your question above, perhaps the following part will do it for you

    required: function() {
        setTimeout(this.errorMessage("InfringementID", "Required"), 10000);
    }
    
    • 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 (bassistance.de/jquery-plugins/jquery-plugin-validation/id) for a bit of client-side form
I am using the JQuery Validation plugin for client side form validation. In addition
I'm using the jQuery.Validation plugin for client side validation, and among other things I
I am using the jQuery validation plugin for client side validation. Function editUser() is
I am using the jQuery Validation plugin and have an issue validating items that
Using the jQuery Validation plugin and AJAX, how can I validate the contents of
I'm using the jQuery Validation plugin and I've got a textbox with the class
Using jQuery, what's the best way to find the next form element on the
Using jQuery , how can I dynamically set the size attribute of a select
Using jQuery, how do you bind a click event to a table cell (below,

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.