Thursday, March 05, 2009

How to disable a calendar button....

When you disable a Datepicker field, you can still click the matching image next to that field and doing so will popup the calendar window.

You can easily get this functionality using jQuery:

$(function(){
$('td.datepicker input:text').each(function(){
var i=this.id;
$('#'+i+'_IMG').click(function()
{return (!document.getElementById(i).disabled);});
});
});

This function adds a click event to the Calendar image that will only return true - and therefore do something - if the date field is enabled. You can see how this works on apex.oracle.com.

Why doesn't APEX handle this by itself? I really don't know. Maybe they'll copy this solution (or similar) in the next version....
Post a Comment