user3652565
user3652565

Reputation: 155

Associating onchange to all fields in a form

I am trying to associate onchange event to all fields in a form using jquery. The code is following

$("#myform").change( function(){
       somethingIsChanged=true;
});

It works well but the issue is if I click on a button in my form operationFormSave is set to true in that case as well. So how can I add onchange on all fields in a form ignoring the buttons or input=button

Upvotes: 0

Views: 967

Answers (2)

xploshioOn
xploshioOn

Reputation: 4115

you can use a class for that

$(".myclassedit").change( function(){
    somethingIsChanged=true;
});

or even if your input's are the same type, you can do this

$( "input[type='text']" ).change(function() {
    somethingIsChanged=true;
});

Upvotes: 0

JKaan
JKaan

Reputation: 329

You could do it like this:

$('input').not('input[type="button"]').change(function() {
    somethingIsChanged=true;
});

Upvotes: 1

Related Questions