jQuery Datepicker with text input that doesn't allow user input

You should be able to use the readonly attribute on the text input, and jQuery will still be able to edit its contents.

<input type='text' id='foo' readonly='true'>

Based on my experience I would recommend the solution suggested by Adhip Gupta:

$("#my_txtbox").attr( 'readOnly' , 'true' );

The following code won't let the user type new characters, but will allow them to delete characters:

$("#my_txtbox").keypress(function(event) {event.preventDefault();});

Additionally, this will render the form useless to those who have JavaScript disabled:

<input type="text" readonly="true" />

try

$("#my_txtbox").keypress(function(event) {event.preventDefault();});

If you are reusing the date-picker at multiple places then it would be apt to modify the textbox also via JavaScript by using something like:

$("#my_txtbox").attr( 'readOnly' , 'true' );

right after/before the place where you initialize your datepicker.