5

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();
});
1
  • 1
    can u share your HTML code ? Commented Dec 18, 2013 at 11:32

1 Answer 1

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

Sign up to request clarification or add additional context in comments.

2 Comments

am getting this error andy in console "event.returnValue is deprecated. Please use the standard event.preventDefault() instead. "
Please try my edited answer. What version of jQuery are you using?

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.