When I make my datepicker read-only, I see that the user cannot type anything into the text box.
$("#datepicker").attr('readonly', 'readonly');
However, they can still change the value using the calendar. How can I hide the calendar so that users cannot change the date value?
I do not want to disable the datepicker since I need the value posted to the server upon form submit.
("#datepicker").datepicker('disable');
$("#datepicker"). attr('readonly', 'readonly');
1 Answer. Show activity on this post. $('#start_date'). datetimepicker({timeFormat: "HH:mm:ss", dateFormat:"dd-mm-yy", constrainInput: false, maxDate: maxdate});
To destroy a datepicker in jQuery UI, we will be using destroy() method. jQuery UI destroy() method is used to remove the complete functionality of the datepicker(). Parameters: This method does not accept any parameters. Return values: This method simply returns the datepicker to its pre-initial state.
I set the following beforeShow event handler (in the options parameter) to achieve this functionality.
beforeShow: function(i) { if ($(i).attr('readonly')) { return false; } }
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