Home Web Development jQuery Solution to: How do I prevent direct editing in a jQuery datepicker...

Get social!

The common answer on the web for this question is to set the readonly attribute in the input tag:

<input id="my-datepicker" readonly="true" name="thedate" />

This indeed works (for most browsers, anyway). However, the input will usually will be rendered as disabled (grayed out) by the browser, which can be confusing to the user.

Solution

Instead, try capturing the keypress event:

19055a9ed7e3adef80e4bacd8bf7f5df000

The datepicker still fires so the user has the calendar to choose the date.

Bad Behavior has blocked 163 access attempts in the last 7 days.