I have a jqueryui datepicker associated with a input text. When i make the input textbox readonly i dont want the datepicker to show up . Is that possible? I would be setting the readonly property to true or false from the code.
<script>
    $(function() {
        $( "#datepicker" ).datepicker();
    });
    </script>
<div class="demo">
<p>Date: <input type="text" id="CompleteDate"> <input class="change" type="checkbox" name="chkBoxb" id="chkBoxb"> </p>
</div>
j$('#chkBoxb').click(function(){
   var paramChangeBoxes = j$('input:checkbox.change');
 if (j$(this).is(':checked')) {
  paramChangeBoxes.removeAttr('checked');
    j$('#chkBoxb').attr('checked', 'checked');
     j$('#CompleteDate').attr('readonly',false);
     j$("#CompleteDate").datepicker();
 }
 else
 {
  j$('#CompleteDate').attr('readonly',true);
 $( "#CompleteDate:not([readonly])"  ).datepicker();
 }
});
Updated the code
DateRangePicker can be inactivated on a page, by setting enabled value as false that will disable the component completely from all the user interactions including in form post.
$("#my_txtbox"). attr( 'readOnly' , 'true' );
You can try the enable/disable methods instead of using the option method: $("#txtSearch"). datepicker("enable"); $("#txtSearch"). datepicker("disable");
Datepicker has a built-in disable method for this you can use, which also disables the text input, like this: $("#datepicker"). datepicker("disable");
disable it like this:
$('#dateSelector').datepicker('disable');
and enable it like this:
$('#dateSelector').datepicker('enable');
Here's a working sample: http://jsfiddle.net/CG64h/8/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With