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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T09:46:02+00:00 2026-05-18T09:46:02+00:00

I’ve got a text field that is wrapped in an error div when the

  • 0

I’ve got a text field that is wrapped in an error div when the user either submits or focuses off an invalid input. I would like to remove the wrapper if the user corrects his mistake, however, the unwrap() method causes the field to lose focus.

$(special_input).live('keyup', function() {
    if (input_okay && input_had_errors) {
        $(this).unwrap();
    }
});

No big deal, I can reset the focus and it works fine…

$(this).unwrap().focus();

…everywhere but in IE! I’ve tried inserting a setTimeOut() function within the above function to get around IE’s lack of support for bubbling of the focus() event, and that works… kinda.

Only problem is it sets the cursor to the beginning of whatever is being typed rather than the end. (WHAT?!)

Resetting the focus seems a little ugly anyway. Is there any way to keep unwrap() from unsetting it in the first place?

Thanks.

Kinda-solution:

For the reasons ender and elusive pointed out, I just decided to fix the problem of the misplaced cursor, which can be done by resetting the value of the textfield after focusing in on it once again. The code looks like this now.

$(this).unwrap();
setTimeout(function() { $(this).focus().val($(this).val()); }, 5);
  • 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-18T09:46:03+00:00Added an answer on May 18, 2026 at 9:46 am

    I do not think that you can .unwrap() without loosing focus, since it removes the parent node from the DOM, and appends the children where the parent was afterwards. You could type in unattached input-fields if the browser wasn’t removing focus when detaching them.

    • 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.