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

The Archive Base Latest Questions

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

Basically I am validating a form, I am collecting the error messages and I

  • 0

Basically I am validating a form, I am collecting the error messages and I am appending them to a div generated dynamiclly. Now I am unable to append these message to this div .here is what I had done

//generates a div onclick of submit button
$("body").append("<div class='overlay'><div class='errorContainer'>.html(errorMsg)</div><div>`<a href='javascript:void(0);' class='cross'>X</a><div></div>");

.html(errorMsg) this causes error/is incorrect

function closeErrorBox() {
            var errorMsg = "";
                var ferrorMsg =  "Please say your first name" + "<br>";
                var aerrorMsg = "Please type address" + "<br>";
                var eerrorMsg = "Please type a valid email Address" + "<br>"
                if($("#name").val() == "") {
                    errorMsg += ferrorMsg;
                }
                if($("#address").val() == "") {
                    errorMsg += aerrorMsg;
                }
                if($("#email").val() == "") {
                    errorMsg += eerrorMsg;
                }

                $(".errorContainer").html(errorMsg);


                $(".overlay").remove();
                }
  • 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-31T21:30:27+00:00Added an answer on May 31, 2026 at 9:30 pm

    The .errorContainer div is inside the .overlay div. When you remove overlay in the end of your function, errorContainer is removed too. Other than that, it seems the .html(errorMsg)
    is working fine (if it still causing error, please specify what’s going wrong).

    Re-reading your question, I couldn’t understand you program’s flow: are you adding that div when the error is already known, and closing it when you click the “X”? If thats the case, I’d suggest doing something like this:

    var errorMsg = "";
    var ferrorMsg =  "Please say your first name" + "<br>";
    var aerrorMsg = "Please type address" + "<br>";
    var eerrorMsg = "Please type a valid email Address" + "<br>"
    if($("#name").val() == "") {
        errorMsg += ferrorMsg;
    }
    if($("#address").val() == "") {
        errorMsg += aerrorMsg;
    }
    if($("#email").val() == "") {
        errorMsg += eerrorMsg;
    }
    
    // Adapting Diego's answer:
    $("<div class='overlay'><div class='errorContainer'></div><div><a href='javascript:void(0);' class='cross'>X</a><div></div>")
        .appendTo($("body"))
        .find(".errorContainer")
            .html(errorMsg)
            .end()
        .find(".cross")
            .click(function(e) {
                e.preventDefault();
                $(this).closest(".overlay").remove();
            });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there anyway to override the custom validation error messages from the ValidationAttributes? Basically
Hi there I am having a problem with my form validation, basically the problem
Can anyone advise where I'm going wrong with my form validation below? Basically if
Yup, basically, I am building a web form that need to provide different required
Basically I have a page named dvds.asp with a form that goes to action=process.asp
I am using the Html.ValidationMessageFor() method to display validation messages on the form. For
I'm having hard times on validating a file input from a zend form with
I have a JSF page that is basically a create form. The form consists
I'm building a Seam application, which is basically a huge form divided into different
So it's a standard in basically every address form out there and I'm questioning

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.