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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T20:36:13+00:00 2026-06-02T20:36:13+00:00

Got a slight problem here. I have a form for a guestbook and each

  • 0

Got a slight problem here. I have a form for a guestbook and each input gets validated so that is its empty, an error message appears. I have adjusted the jquery section so that the error message is delayed for 2 seconds, before fading out as shown below:

$(document).ready(function(){

var working = false;

$('#addCommentForm').submit(function(e){

    e.preventDefault();
    if(working) return false;

    working = true;
    $('#submit').val('Working..');
    $('.error').remove();

    $.post('submit.php',$(this).serialize(),function(msg){

        working = false;
        $('#submit').val('Submit');

        if(msg.status){

            $(msg.html).hide().insertAfter('#new').slideDown();
            $('#body').val('');
        }


        else {
            /* This is the section im stuck with */
            $.each(msg.errors,function(k,v){
                $('[for='+k+']').append('<div class="error">'+v+'</div>').delay(2000).fadeOut();
            });

        }

    },'json');

});

});

However, after the error message fades out, the label also disappears. I have the feeling its to do with this part of the code:

'[for='+k+']'

Is there any way I can get around this, so that only the error message fades out rather than the label too?

Should you require any more code from me, please let me know.

  • 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-02T20:36:15+00:00Added an answer on June 2, 2026 at 8:36 pm

    You’re right :

    $('[for='+k+']').append('<div class="error">'+v+'</div>').delay(2000).fadeOut();
    

    means you append an element, wait, and fadeOut any element with [for=…] selected.

    A solution could be using appendTo()

    $('<div class="error">'+v+'</div>').appendTo('[for='+k+']').delay(2000).fadeOut();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Got a slight problem trying to have jquery UI and knockout js to cohoperate.
Right, I've got a slight problem here, in which I've attempted to implement a
I have here a slight problem. We have written a big spring based application
just got a slight problem here with updating a MySql DataGridView from visual studio
I got a slight problem, I'm getting a error saying 'UIPickerView' undeclared on line
Got some code that is not mine and its producing this warning atm: iehtmlwin.cpp(264)
I've got a slight problem when using a generic repository with EF4. First let
I have a slight problem implementing vibration functionality in my application. My code is:
i've got a slight jQuery problem. What i want is to load a particular
I've got some Workflow Foundation 4 ActivityDesigners that I'd like to have interact with

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.