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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T23:42:40+00:00 2026-06-05T23:42:40+00:00

I want to do input validation with jQuery. Every time the user blurs an

  • 0

I want to do input validation with jQuery. Every time the user blurs an input, it should get validated. The validation is not the problem, it’s the focus part.

Some inputs are embedded in a bigger parent element. The parent element should be the indicator for focusin and focusout events. In other words: If the user clicks on the parent element of the input, it should focus the input.

Here is a demonstration:

DEMO on jsFiddle

In the demo, the first input is surrounded by a ul which is clickable and causes the underlying input to focus. The second input is surrounded by a div which does nothing. Watch the console for the output.

Here is the markup taken from the demo. HTML:

<ul>
<li>
    <input type="text" class="embed" />
</li>
</ul>

<div>
    <input type="text" class="normal" />
</div>​

JavaScript:

$('input').focusin(function(event) {
    console.log('input.' + $(this).attr('class') + ' focusin');
});

$('input').focusout(function(event) {
    console.log('input.' + $(this).attr('class') + ' focusout');
    // either here or in blur:
    // now i want to do some validation and display errors if there are any
});

$('input').blur(function(event) {
    console.log('input.' + $(this).attr('class') + ' blur');
    // either here or in focusout:
    // now i want to do some validation and display errors if there are any
});

$('ul').click(function(event){
    console.log('ul click');
    $('input.embed').focus();
});
​

Currently these are my questions and problems:

  1. When clicking on the embedded input, it also fires the ul click event, which i do not want. How can i detect in that event if the input was clicked directly?
  2. If the embedded input is already focused, and i click on the parent ul, it fires the focusout event of the input (which would trigger the validation) and immediately focuses it again because of the ul click handler. How can detect this and simply do nothing? Because in fact, from the point of view of the user, the focus didn’t change.
  3. What’s the difference between blur and focusout?
  • 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-05T23:42:43+00:00Added an answer on June 5, 2026 at 11:42 pm

    For your first question:

    $('ul input.embed').click(function(event){
        event.stopPropagation();
    });
    

    For your third question, from jQuery api documentation:

    The focusout event is sent to an element when it, or any element
    inside of it, loses focus. This is distinct from the blur event in
    that it supports detecting the loss of focus from parent elements (in
    other words, it supports event bubbling).

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

Sidebar

Related Questions

I have some problem. Dialog.dismiss() does not work. I want to input ip, username,
I am building a site which uses jQUery validation plugin and want things validated
I am creating a form which is validated under jQuery Validation . I want
I want make validation jquery without using from plugin , problem is here that
I want to input data i.e. name and age of user on a scene
I have a codeigniter webform, I want to input city/state details from the user,
Greeting, I'm using jquery Plugins/Validation library. I want to allow validation on submitting but
I'm having a hard time getting the jQuery Validation plugin to work as I
Every time a user registers to our site we need to show a NDA
I'm using the jQuery validation plugin, and I want to add a class to

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.