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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T08:34:08+00:00 2026-06-15T08:34:08+00:00

I am validating some text inputs using the keyup function, and I want to

  • 0

I am validating some text inputs using the keyup function, and I want to run an animation of a check mark when the box is considered validated.

The problem is that as soon as I click into any input, the animation starts. If you type once as soon as you click in, you will see the animation happen. I’m assuming the animation starts because i’m adding the class on keyup, which essentially get’s triggered after you release your mouse to click into it. Is there another way around that?

  1. I increased the time to 5 seconds just while testing it
  2. Why is it triggering all 3 animations since i’m using the each and the next functions.
  3. Is there a way around having the animation start on keyup.

The gist of my code is below, see a live version here: http://jsfiddle.net/MhMCz/26/

$(':input').each(function(){
   var values = $(this).attr('value');

   $(this).keyup(function(){
      if( $(this).val() !== '' && $(this).val() !== values) {
        $(this).addClass('animated');
        $(this).next('span').html("<img src='http://png.findicons.com/files/icons/1581/silk/16/tick.png' />");
    }
    else {
       $(this).removeClass('animated'); 
       $(this).next('span').html('');     
    }                
   });

   if ( $(this).next('span').hasClass('animated') ) { }
   else {
      $(this).next('span').animate({
           marginLeft: '10px'
        }, 5000, function(){
           alert("animation complete")
   });   
}
)};
  • 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-15T08:34:10+00:00Added an answer on June 15, 2026 at 8:34 am

    I reconstructured your code a little, could be optimzed more but it looks quite nice:

    http://jsfiddle.net/MhMCz/30/

    $('form').on('focus focusin blur focusout keyup', ':input', function(e) {
        var val = this.value,
            def = this.defaultValue,
            $t = $(this),
            $check = $t.next('span');
    
        switch(e.type){
            case 'focus':
            case 'focusin':
                if( val == def ) {
                   this.value = '';
                   $t.addClass('active');
                }
            break;
            case 'blur':
            case 'focusout':
                if(val == '') this.value = def;
                $t.removeClass('active');
            break;
            case 'keyup':
                if(val != '' && val != def) {
                    $check.animate({
                        opacity: 1,
                        'margin-left': '10px'
                    }, 'fast');
                } else {
                   $check.animate({
                        opacity: 0,
                        'margin-left': '100px'
                   }, 'fast');   
                }
            break;
        }
    });
    

    The event delegation from “form” ist just for performance, see http://jsperf.com/jquery-live-vs-delegate-vs-on/4.

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

Sidebar

Related Questions

I want to validate some text boxes in my ASP.NET page using ASP required
I am trying to encrypt some plain text with a public key using RSA_public_encrypt(),
I'm validating some input ( type=text ) boxes with JavaScript (jQuery). They are on
I'm trying to add some Input Validation in Classic ASP by using the function/code
I am currently using a email form, which posts some text once the email
I have a form that I'm trying to run some basic validation on using
I am looking at validation of some text boxes for things like required, minlength,
I'll admit, I'm an XML newbie. I'm having trouble validating some xml against a
I've setup some Nunit tests for validating my statistical formulas within my .net v2
I am validating XML documents against a schema. Some more complex documents/schemas always fail

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.