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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T21:51:24+00:00 2026-05-12T21:51:24+00:00

I have an input field that has a field hint that comes up when

  • 0

I have an input field that has a field hint that comes up when focused. The problem is that I am using prototype effects and have the hint Effect.toggle ‘ing, and if someone types in the field, then backspaces, the hint gets all backwards. Is there a way to set a var or case or something that can be set while the input has focus?

   function fieldHint(fieldName,cloneField){
        var hint = $(fieldName);
        var clone = $(cloneField);
        //only show fieldhint if input is empty
        if(clone.value==''){
            Effect.toggle(hint,'appear', { duration: 0.3 });
            //clone position of input box for fieldhint
            hint.clonePosition(clone,{
                offsetTop: 18,
                offsetLeft: 15,
                });
        }
    }
    function disableFieldHint(input,why,fieldName){
        var hint = $(fieldName);
        var input = $(input);
        var inputLength = input.value.length;
        if(why=='key' && inputLength<1){
            Effect.toggle(hint,'appear', { duration: 0.1 });
        }
        if(why=='blur' && inputLength<1){
            Effect.toggle(hint,'appear', { duration: 0.1 });
        }
    }

I call the fieldHint() via onFocus and call disableFieldHint() via either onBlur or onKeyDown… So I think it’s getting confused because onKeyDown works initially to hide the hint, but if peeps type then backspace everything, then start typing again, that onKeyDown + value=”” will be true, and since fieldHint() is a toggle, it will show the fieldhint again while people are typing, and everything is divided by zero – unless peeps then backspace again and start typing again, then everything leaves upside down world – unless they backspace again and start typing again, then it’s all fubar and like opposite day for a few seconds.

I understand that I could just use style.display to show or hide the hint, but the fades make me look much more like I know what I’m doing (which is obviously not true).

Thank you kindly, good Gentlemen.

  • 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-12T21:51:24+00:00Added an answer on May 12, 2026 at 9:51 pm

    I would set a flag when onKeyDown is fired, and clear it for onBlur, something like fieldName.hasStartedInput = true. This way, you can check the flag before you try show the hint and if it is true, don’t show the hint.

    Edit: Addressing the new code that you posted. It’s a little convoluted and repetitive, so I’ve trimmed it down a little for you. I don’t have all of your code, so I can’t test it obviously, but you should at least be able to get the idea.

    var typing = false, first = false;
    
    function isTyping(areThey) {
        typing = areThey;
    }
    
    function fieldHint(fieldName, cloneField) {
            var hint  = $(fieldName);
            var clone = $(cloneField);
    
            // only show fieldhint if input is empty
            if ( clone.value == '' && !typing && !first ) {
                    first = true;
                    Effect.toggle(hint, 'appear', { duration: 0.3 });
                    //clone position of input box for fieldhint
                    hint.clonePosition(clone, {
                            offsetTop: 18,
                            offsetLeft: 15,
                    });
            }
    }
    
    function disableFieldHint(input, why, fieldName) {
        var hint = $(fieldName);
        if ( why == 'key' && typing && first && $(input).value.length == 0 ) {
            Effect.toggle(hint, 'appear', { duration: 0.1 });
            first = false;
        }
        else if ( why == 'blur' && typing == first ) {
            Effect.toggle(, 'appear', { duration: 0.1 });
        }
    }
    

    The big point is don’t forget that JavaScript has real boolean types, meaning that you can use true and false, not 0 and 1, or "TRUE" and "FALSE". With that said, you’ll have to update in your own code wherever isTyping() is called and make sure that you are passing in a boolean type, not the string "TRUE" or "FALSE".

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

Sidebar

Related Questions

No related questions found

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.