4

Need solution how to enable and disable text field using jquery when document is ready. Sample code which i tried is as follows, but am not getting any output nor alert are getting displayed.

jQuery(document).ready(function(){
     /*jQuery('#tan label.control input').change();*/
});
jQuery("#cca label.control input").on('change', function (event) {
  alert('I am pretty sure the text box changed');
  event.preventDefault();
});
Bram Vanroy
  • 22,919
  • 16
  • 101
  • 195
jasim
  • 238
  • 1
  • 4
  • 15

1 Answers1

0

Try this:

jQuery(document).ready(function(){
     jQuery("#cca label.control input").on('change', function (e) {
    alert('I am pretty sure the text box changed');
    e.preventDefault();
  });
});

If that doesn't work then please respond with what your console returns when you type jQuery("#cca label.control input").length

andy
  • 2,279
  • 1
  • 26
  • 45
  • am getting this error andy in console "event.returnValue is deprecated. Please use the standard event.preventDefault() instead. " – jasim Dec 18 '13 at 11:52
  • Please try my edited answer. What version of jQuery are you using? – andy Dec 18 '13 at 12:48