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

  • Home
  • SEARCH
  • 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 7795751
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T23:09:35+00:00 2026-06-01T23:09:35+00:00

I have that text field: <input type=’text’ id=’title’ name=’title’> <div id=’error’ class=’error’></div> When user

  • 0

I have that text field:

<input type='text' id='title' name='title'>
<div id='error' class='error'></div>

When user clicks out of the text field and there is a validation problem, the div “error” appears.

What I want to do is to hide that little div when user clicks anywhere in the body.
I tried e.stopPropagation in the body click event but didn’t work.

The div never appears because when I blur out of the textfield, it’s considered a body click

Please let me know if you have any idea. Regards

EDIT:
I have updated the code. The code inside the body click event is supposed to hide the “error” div when anything but the text field is clicked, but can’t get it to work.

$('body').click(function(event){
        if ($(event.target).closest('#title').get(0) == null ) { 
            $("#error").hide(); 
            }});

// Validation
$('#title').blur(function(){
    var titleinput=$('#title').val();
    if (titleinput.length <30 || titleinput.length >50){
        $('#error').text('Your title must be between 30 and 50 characters').show();
        }
    });
  • 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-01T23:09:36+00:00Added an answer on June 1, 2026 at 11:09 pm

    Unfortunately, since blur and click are different events, you can’t use stopPropagation. The only way I can think to do this is to fake it. You can ignore the first click that happens within a fraction of a second of the blur event.

    http://jsfiddle.net/LeNDp/1

    var ignoreClicks = false;
    var timer;
    
    $("body").click(function() {
        if(!ignoreClicks){
            $("#msg").fadeOut();
        }else{
            if(timer) clearTimeout(timer);
            ignoreClicks = false;        
        }
    });
    
    $("input").blur(function(e) {
        ignoreClicks = true;      
        $("#msg").stop(true,true).show();
    
        if(timer) clearTimeout(timer);
        timer = setTimeout(function(){ignoreClicks=false;}, 250);
    });​
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a jQuery jPicker colorpicker that is bound to an input text field
I would like to have a text field that a user can enter a
I have model Article it has field title with some text that may contain
In my app I have a text field that takes some number input from
I have a text input field that has some sample text in a light
I have an input field like the following: <input class=... maxlength=... title=... size=... value=...
I have a ruby on rails application with an input text field that has
I understand that text_field creates an input field of type text , while email_field
I have an input field on my page where the user will type in
I have a input type number. Once the user enters the number in that

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.