Hi Friend's
Disable past and current date selection in admin form edit/add action
Open your form.php file and add this code
Code:
$nextdate = $fieldset->addField('next_date'.$counter, 'date',
array(
'name' => 'upcoming_date',
'label' => 'Upcomng Date',
'class' => 'required-entry validate-date validate-date-range date-range-custom_theme-from',
'required' => true,
'image' => $this->getSkinUrl('images/grid-cal.gif'),
'format' => 'YYYY-MM-dd'
)
);
$nextdate->setAfterElementHtml("<p>Date format is <strong style='color: #FF0000;'>YYYY</strong>/<strong style='color: #FF0000;'>MM</strong>/<strong style='color: #FF0000;'>DD</strong></p>
<script type=\"text/javascript\">
//<![CDATA[
Calendar.setup({
inputField: 'upcoming_date',
ifFormat: '%Y-%m-%d',
showsTime: false,
button: 'upcoming_date_trig',
align: 'Bl',
singleClick : true,
disableFunc: function(date) {
var now = new Date();
//If you want to disable current date so remove below comment
//now.setDate(now.getDate() + 1);
if(date.getFullYear() < now.getFullYear()) { return true; }
if(date.getFullYear() == now.getFullYear()) { if(date.getMonth() < now.getMonth()) { return true; } }
if(date.getMonth() == now.getMonth()) { if(date.getDate() < now.getDate()) { return true; } }
}
});
//]]>
</script>");
Now Flush Magento Cache and refresh page
Hope this information is helpful to you :)
Really Helpful Blog
ReplyDeleteThis comment has been removed by the author.
ReplyDeletethanks for this if want user click on sat n sun then how to open alert message
ReplyDelete