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
  • 24,991
  • 21
  • 120
  • 214
jasim
  • 248
  • 1
  • 5
  • 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,331
  • 1
  • 29
  • 48
  • 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