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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T09:11:11+00:00 2026-05-31T09:11:11+00:00

I am in the process of applying validation on a web form -one of

  • 0

I am in the process of applying validation on a web form -one of the things I would like to do is add a pulsing border to the div which contains the erroneous input.

This solution: border highlighting loop with jquery and http://jsfiddle.net/Ue4wy/4/ pretty much hits the mark.

But I want to be able to fade the yellow border to black on the click handler & reset the loop (this example pauses the loop), so the next time the user hits submit it starts again.

Reseting the colour to black works using the code below (though I am sure there is a more elegant solution), but how do I reset the loop?

    $('#weight').animate({
        borderBottomColor: '#000',
        borderLeftColor: '#000',
        borderRightColor: '#000',
        borderTopColor : '#000'
    }, 'fast' );

Any ideas appreciated!

  • 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-31T09:11:12+00:00Added an answer on May 31, 2026 at 9:11 am

    I’ve updated the update() function to accept an argument, i, which is then called in the click handler, along with window.clearTimeout():

    var addClickHandler = function() {
        $("div").click(function() {
            window.clearTimeout(timer);
            update(0);
    
        });
    };
    

    This does require that the other calls to update() also need to pass the i:

    var update = function(i) {
        $("div").css("border-color", 'rgb(' + i + ',' + i + ',' + 0 + ')');
    };
    

    JS Fiddle demo.


    Edited to amend the click-handler to offer a toggle (stop/start) for the animation:

    var addClickHandler = function() {
        $("div").toggle(function() {
            window.clearTimeout(timer);
            update(0);
    
        }, function() {
            anim.go();
        });
    };
    

    JS Fiddle demo.


    Edited for a slightly more context-aware click-handler, this version checks for the existence of the timer variable and, if it isn’t found, starts the animation. If it is found then it clears the timeout, sets the timer to false and calls update(0) to reset the borders to black:

    var addClickHandler = function() {
        $("div").click(function() {
            console.log(timer);
            if (!timer){
                timer = window.setTimeout(anim.go, 30);
            }
            else {
                window.clearTimeout(timer);
                timer = false;
                update(0);
            }
    
        });
    

    JS Fiddle demo.

    References:

    • toggle().
    • window.clearTimeout().
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

During one of my project i need to add required field validation on the
There is a conversion process that is needed when migrating Visual Studio 2005 web
I'm in the process of refactoring some code which includes moving folders around, and
I have a fluent interface for an IoC container registration process, and this contains
Process the data handed to an html page from a form. This is my
OCaml process can use just one core and in order to use multiple cores
I am repeatedly applying a function to read and process a bunch of csv
I'm using XSLT to process my ASP.Net web.config file to insert some extra log4net
I think I may be applying too much of my normal context (web app
I'm in the process of applying an "HTML4.5" approach to an existing XHTML 1.0

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.