0

I will need to detect if ALL form change for all element,

I tried

$('input, select').change(function(){
  alert(' work! ');
});

$('#formID').change(function(){
  alert(' work too !');
});

$('textarea, input[type=radio]').change(function(){
  alert(' Wont fire ?? ');
});

How do I detect change on textarea, radio button and checkbox ?

Peter
  • 1,481
  • 4
  • 19
  • 37
  • works fine - http://jsfiddle.net/arunpjohny/1dhqnxag/1/ – Arun P Johny Sep 19 '14 at 02:24
  • look like I have some other jquery preventing such change – Peter Sep 19 '14 at 02:31
  • could be... but since the handlers are attached to the element's itself the only reason for it to not fire is if there is a call to [event.stopImmediatePropagation()](http://api.jquery.com/event.stopimmediatepropagation/) or you are creating those elements in a dynamic way after the handler registration code is executed(in such case have a look at [event delegation](http://learn.jquery.com/events/event-delegation/)) – Arun P Johny Sep 19 '14 at 02:34
  • I added $(document).on('change', 'input', function() { console.log(' but no luck') }); anyway thanks for help – Peter Sep 19 '14 at 03:02

2 Answers2

0
$('#textareaID').bind('input propertychange', function() {

      $("#yourBtnID").hide();

      if(this.value.length){
        $("#yourBtnID").show();
      }
});

Which is copied form here

and for radio button change

$("input[name=someRadioGroup]:radio").change(function () {
Community
  • 1
  • 1
Just code
  • 13,553
  • 10
  • 51
  • 93
0

1. Assign unique id (ex: id="sampleName") to textarea and common name to the necessary radio buttons (ex: name="sampleName")

2. Use the following Jquery stuff,

$('#sampleName').change(function(){
  alert(' work!');
});

$("input[name=sampleName]:radio").change(function(){
  alert(' work!');
});
Community
  • 1
  • 1
Manoj Namodurai
  • 529
  • 2
  • 7