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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T07:57:52+00:00 2026-05-28T07:57:52+00:00

I have created some JQuery that on click of specified HTML it then becomes

  • 0

I have created some JQuery that on click of specified HTML it then becomes editable via an input box and when the user either clicks enter or clicks off (ie the text box looses focus) it assigns the value to the text box to the HTML. This works fine (as far as I can tell).

To validate the input to ensure that there is not empty value I have an alert box that pops up both on loose focus (.blur) and on enter press to inform the user that the value is empty and the value is not assigned. These work to a degree.

My two problems are as follows:

The on enter press alert box pops up multiple times on one press and I am unsure as to why.

After the on enter press alert box is closed the loose focus (.blur) function no longer works.

I appreciate any help or guidance you folks can offer.

My code:

$(document).ready(function () {
$(".imageHolder").hover(function () {
    $(this).append('<div class="xdiv"></div>');
    if ($('.titleinput', this).length) {
        $(".xdiv").remove();
    }
    $(".imageName", this).click(function () {
        imageName = $(this);
        parent_div = $(this).parent();
        image_val = $.trim($(this).html())
        $(".formtags").remove();
        $(".imageName").show();
        $(imageName).hide();
        $(parent_div).append('<form class="formtags"><input class="titleinput" type="text" name="ImageTitle" /></form>');
        $(".titleinput").focus(function(){
        this.select();
        });
        $(".titleinput", parent_div).val(image_val);
        $(".xdiv").remove();
        $(".titleinput").blur(function() {
            if($(".titleinput").val() == '') {
            alert("Please enter Image Title Focus Lost");
            } else {
        image_val = $(".titleinput").val();
        $(imageName).html(image_val);
        $(".formtags").remove();
        $(".imageName").show();
            }
        });
        $(document).keypress(function (e) {
            if (e.keyCode == 13 && $(".titleinput",this).val() == '') {
                $(".formtags").remove();
                $(parent_div).append('<form class="formtags"><input class="titleinput" type="text" name="ImageTitle" /></form>');
                alert("Please enter Image Title Enter Pressed");
                e.preventDefault();
                } else if (e.keyCode == 13) {
                image_val = $(".titleinput").val();
                $(imageName).html(image_val);
                $(".formtags").remove();
                $(".imageName").show();
                e.preventDefault();
            }
        });
    });
    $(".xdiv").click(function () {
        alert('Click Handler Called');
    });
}, function () {
    $(".xdiv", this).remove();
});
$(".imageName", this).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-05-28T07:57:52+00:00Added an answer on May 28, 2026 at 7:57 am

    Two things

    1) Don’t use alerts to validate content, it’s not a good practice. I can suggest you to use this (validity) jQuery plugin. Read the documentation and find there ‘Using Validity with Ajax‘ header (it can handle dynamically added inputs)

    2) Second thing. But I’m not sure if I’m right about this issue. Check if you don’t do something like this in your code (maybe it’s not a loop in your code but pretty much this kind of behaviour, a few times ‘binding’ event to function) jsFiddle example of few times binding event. And if this is the problem try doing this

    $('#elementId').unbind('click').bind('click', function() {
    //some code here
    });

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

Sidebar

Related Questions

I created some widgets with jQuery UI and I notice that buttons have a
I have created a form that must pass validation via JQuery to see if
I have some elements created with jQuery that are added in a iframe. I
I have created a nice tooltip box using JQuery and I used some plugin
I have created a simple JQuery script with hovering effect on some links. The
I have created some functional categories that I use to show/hide markup elements. However,
I have been adding new elements via jQuery in some of my projects, and
Hello i am written some script in jquery and bind that to a click
I have some tabs created with jquery and i want to add new tabs.
I have a problem with this function: $(#contentdiv).click(function() { $(this).append(<div class='editable'>For some reason this

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.