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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T10:20:33+00:00 2026-05-13T10:20:33+00:00

I have the following code to count and trigger some functions using jQuery: jQuery(‘#input_guideName’).keyup(function(e)

  • 0

I have the following code to count and trigger some functions using jQuery:

        jQuery('#input_guideName').keyup(function(e)
        {               
            if(this.value.length == 5)
            {
                jQuery("#guide_btnCreateGuide").css({'background-position':'top', 'cursor':'pointer'});
                jQuery("#guide_btnCreateGuide").bind('click', function() {
                    createNewGuide(); 
                });
            }
            else if(this.value.length < 5)
            {
                jQuery("#guide_btnCreateGuide").css({'background-position':'bottom', 'cursor':'default'});
                jQuery("#guide_btnCreateGuide").unbind('click');
            }
        });   

Here are some issues I have encountered:

  1. Using CTRL + V is counted as 2 keyup, and the code will run twice, executing the createNewGuide() twice. How can I avoid this?

  2. Pasting code using right mouse button is not detected. How can I detect this? Bu putting a listener on RightMouseButton?

  3. If I paste text > 5 characters, none of my functions are triggered. I cannot add a control on if(this.value.length > 5), because then createNewGuide(); will fire for each keyup.

Any ideas how I can overcome these issues?

EDIT
My “operational objective” is to create a new guide in DB and the guide name must be at least 5 characters long. The button for the ‘create guide’ will not be clickable unless name is at least 5 characters long.

  • 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-13T10:20:33+00:00Added an answer on May 13, 2026 at 10:20 am

    Handling Ctrl + V isn’t as bad as you might think but handling paste in general is. There’s no onpaste event (at least not cross browser) and the middle/right click paste actually happens AFTER the mouseup event so if you just did .bind('change keyup mouseup', func... you’d miss it. Given all that, I think a timeout is the best way to do this:

    $(function() {
    setTimeout(function() {
        var val = jQuery('#input_guideName').val();
    
        if (val.length > 5) {
            jQuery("#guide_btnCreateGuide")
              .css({'background-position':'top', 'cursor':'pointer'})
              .unbind('click')  // prevents duplicate click events
              .bind('click', function() {
                    createNewGuide(); 
              });
        } else {
            jQuery("#guide_btnCreateGuide")
              .css({'background-position':'bottom', 'cursor':'default'})
              .unbind('click');
        }
    
    }, 300);
    });
    

    Even in your original code, createNewGuide() wasn’t being called on each keyup with this.value > 5 but rather you were registering a new event on each keyup that call createNewGuide, so then on click, it would get called multiple times.

    By doing unbind before bind prevents duplicate functions getting registered onclick, so you won’t ever call createNewGuide() twice, even on ctrl + v;

    You can tune the delay if you’re worried about your users hitting the button quickly after shorting the input.

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

Sidebar

Related Questions

I have the following code: Some functions: A::A(int i_a) {cout<<int Ctor\n;} //conversion constructor void
I have used the following code to generate some dynamic checkboxes. This works for
I have this following code: if (userValueSom01 == realResult01) { //answer = correct //count
I have the following code, I am trying to simply count to ten using
I have the following code $result = $handle->select()->from('store_products_id', array('count'=>'COUNT(store_products_id.product_id)')) ->where('store_products_id.store_id=?', $this->store_id) ->columns($selectColumns) ->join('product_quickinfo', 'store_products_id.product_id
I have the following jquery code: while (count < 31) { window['cday_' + count]
I have the following code. What I want to do is count the frequency
I have the following code: NSLog(@items: %d, [items count]); NSLog(@allObjects: %d, [self.allObjects count]); [self.allObjects
I have the following code: <div id=content> <?php if(count($app->getMessageQueue())) { ?> <jdoc:include type=message />
I have the following mySQL code: SELECT c.categoryId, c.categoryName, c.categoryParent, c.categoryDescription, COUNT(p.productid) as totalProdsInCategory

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.