DatePicker beforeShow how to stop show process ?

DatePicker beforeShow how to stop show process ?

Hi,
 
I am doing some tests inside beforeShow and depending the tests result I would like to avoid DatePicker to popup, is it possible ?
 
$('#MyDate')
    .datepicker({
     beforeShow:
     function(){
      myerror = true;
      if ( myerror == true)
      {
        // how avoid DatePicker popup ?






      }
     }
    });
 
I also tried to add a .click but the .click never trigger, .datepicker seems to override it, so I tried to use only .click and then inside .click popup the datepicker but I couldn't popup the dialog, I get some "settings not defined".
 
regards.