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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T01:42:11+00:00 2026-05-17T01:42:11+00:00

I’ve got a custom errorPlacement function that is updating a seperate message container with

  • 0

I’ve got a custom errorPlacement function that is updating a seperate message container with a custom way of displaying error messages.

As part of the form I’m validating, I have a fair number of input text boxes to validate (think lines of numbers being checked against some kind of result), and as part of this need the error messages to only show once in my custom container.

My code looks like this:

errorPlacement: function(errorMessageElement, field) {  
    if(errorMessageElement[0].innerHTML != "") {
        if(!$("#alertbar ul li.error").length) { window.scrollTo(0,0); }

        var errorMessageText = errorMessageElement[0].innerHTML;
        var errorLine = errorMessageElement.attr('for').substr(0,4);
        var countIdenticalLineMessages = $("#alertbar ul li[id~='" + errorLine + "']:contains('" + errorMessageText + "')").length;

        var errorMessageId = "error-" + errorMessageElement.attr('for');

        if (countIdenticalLineMessages < 1) {   
            if(!$("#alertbar ul li[id='" + errorMessageId + "']").length) {
                $('#alertbar ul').append("<li id='" + errorMessageId + "' class='error' />");   
            }
            var fieldErrorContainer = $("#alertbar ul li[id='" + errorMessageId + "']");
            var errorContainerHTML = "<span class='hide'>Error - <\/span>" + errorMessageElement[0].innerHTML;      
            fieldErrorContainer.html(errorContainerHTML);
        } else {
            var newErrorLineId = "lineerror-" + errorMessageElement.attr('for').substr(0,4);    
            if(!$("#alertbar ul li[id='" + newErrorLineId + "']").length) {
                // the below line doesn't fire till somewhere else on the page is clicked.
                $("#alertbar ul li[id='" + errorMessageId + "']").attr("id", newErrorLineId);   
            }
            var currentLineList = [];
            if($("#alertbar").data(errorLine)) { currentLineList = $("#alertbar").data(errorLine); }

            if(currentLineList.indexOf(errorMessageElement.attr('for')) == -1) { currentLineList.push(errorMessageElement.attr('for')) };
            $("#alertbar").data(errorLine, currentLineList);
        }
        CoreErrorHandling.updateErrorSummary();
    };

}

But the bit that switches the id of the line error li isn’t firing till I click away from the focussed element, or tab away.

Is errorPlacement firing too quick for it to respond or am I missing something?

  • 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-17T01:42:12+00:00Added an answer on May 17, 2026 at 1:42 am

    No worries, I found the problem: I’d got a couple of the lines in the wrong order right in the middle, so the event was always firing late! Somedays it’s hard to see the wood for the trees!

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

Sidebar

Related Questions

I've got a string that has curly quotes in it. I'd like to replace
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 need a function that will clean a strings' special characters. I do NOT
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a French site that I want to parse, but am running into
I am doing a simple coin flipping experiment for class that involves flipping a
i got an object with contents of html markup in it, for example: string
I want to construct a data frame in an Rcpp function, but when 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.