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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T16:04:49+00:00 2026-05-28T16:04:49+00:00

html : <div id=’myform’> Name : <input type=’text’/> Age : <input type=’text’/> ….. <input

  • 0

html :

<div id='myform'>
    Name : <input type='text'/>
    Age : <input type='text'/>
    .....
    <input type='button' class='mysavebutton' value='save'/>
</div>

html script :

$(document).ready(function(){
    $("#myform input:button").click(function(){
        //do save
        alert("Save complete.");
    });  
});

the problem is :
how to add function to #myform input:button before “do save” without change anycode above.. (like add plugins)

i already create somthing like this

$(document).ready(function () {
    $(".mysavebutton").each(function () {
        $(this).data("old_click", $(this).click); // <----- here the problem #1. how to keep click function.

        $(this).unbind("click").click(function () {
            parent = $(this).parents("body");

            $(parent).find("input:textbox").each(function () {
                validate_object(this); //this function validate all textbox on body and add error class to textbox if error
            });

            if ($(parent).find("input:type.error").length == 0) {
                //no error. than call old function
                $(this).data("old_click");  //eval($(this).data("old_click"))
            }
            else {
                 //not run old_click coz error
                alert("Invalid data.")
            }
        });
    });
});

if possible, repair. if not, please give other solution. thanx

  • 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-28T16:04:50+00:00Added an answer on May 28, 2026 at 4:04 pm
    $(document).ready(function () {
      $(".mysavebutton").each(function () {
        $(this).data("old_click", $(this).data('events')['click'][0].handler);
    
        $(this).unbind("click").click(function () {
            //get the form
            var parent = $(this).closest('form');
    
            $(parent).find("input:textbox").each(function () {
                validate_object(this); //this function validate all textbox on body and add error class to textbox if error
            });
    
            if ($(parent).find("input:type.error").length == 0) {
                //no error. than call old function
                $(this).data("old_click").apply(this, arguments);
            }
            else {
                 //not run old_click coz error
                alert("Invalid data.")
            }
        });
    });
    });
    

    Might be a better way but this should work.

    http://jsfiddle.net/GhLSS/1/

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

Sidebar

Related Questions

Suppose the following HTML div container <div id=container> <form> <div> <label class=error>Name</label> <input type=text
$(function() { var div = $('div'); $('input').click(function() { if($(this).is(':checked')) { div.html(div.text() += 49); }
I have this html div tag defined: <div style=height:100px; width:100px class=total-title> first text </div>
I'm using custom radiobuttons with a SQLFORM as shown below: def radioboxes(field,value): items=[DIV(name,INPUT(_type='radio',_value=key,_name=field.name,value=value), _class='radio')
here is link to an example: http://techchorus.net/demos/jquery/hiding-input-elements-in-a-div.html It actally disables few elements on click
$('div.box').html(hello) puts the word hello inside all my div's of class 'box'. They all
it must be jquery I have file text.html with 6 div in (a,b,c,d,e,f) In
My HTML looks like and js looks like this: <div class=container></div> var html =
I have a simle html div with a variable number of input checkboxes and
I have html div class formated accordingly.... <div class=latest-media-images> <div class=hdr-article>LATEST IMAGES</div> <a class=lnk-thumb

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.