开发者

How do I know if a form has been modified

开发者 https://www.devze.com 2022-12-09 05:20 出处:网络
I Would like to know if there is anyway I can 开发者_如何转开发check if a form has been modified.

I Would like to know if there is anyway I can 开发者_如何转开发check if a form has been modified.

eg. If one of the inputs has been changed I would like to display a button to submit the changes.


There's a "change" event with JQuery. So doing something like :

$(document).ready(function() {
    $('form').change(function() {
        # Here you display your button
    }
}

Will perfectly work (and your javascript remains independant from your html).


There is a attribute called: onchange="JAVASCRIPTFUNCTION();"

JavaScript Example:

<form onchange="displayButton();"> </form>

.

Full explaination: CLICK (w3schools.com is one of the best resources out there)

// // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // //

jQuery Example:

$(FORM_ID).change(function(){
    $(BUTTON_ID).show();
});


Using JQuery you could use the on change event.

$('#form_id input').change(function(){
    $('#button').show();
});

The button can be hidden in the meantime.

0

精彩评论

暂无评论...
验证码 换一张
取 消