-
Salesforce Visualforce Page - Disable previous date in calendar
VF Page-
<apex:page showHeader="false" controller="Test4">
<head>
<apex:stylesheet value="https://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" />
<apex:includeScript value="https://code.jquery.com/jquery-1.9.1.js" />
<apex:includeScript value="https://code.jquery.com/ui/1.10.3/jquery-ui.js" />
</head><script>
var today = new Date();
$("#datepicker").datepicker({
changeMonth: true,
changeYear: true,
minDate: today
});
</script>
<apex:form >
<apex:pageBlock >
<apex:selectList value="{!selectId}" size="1">
<apex:selectOptions value="{!displayOptions}"></apex:selectOptions>
<apex:actionSupport event="onchange" action="{!changeDateRange}" reRender="calender"/>
</apex:selectList>
<input type="text" id="datepicker"/>
</apex:pageBlock>
</apex:form>
</apex:page>Controller-
public class Test4 {
public List<selectoption> displayOptions { get; set; }
public String selectId { get; set; }
public Date myDate {get;set;}public PageReference changeDateRange() {
myDate = Date.today();
if(selectId.equals('10')){
myDate = myDate.addDays(10);
} else if(selectId.equals('20')){
myDate = myDate.addDays(20);
}
return null;
}public test4()
{
myDate = Date.today();
displayOptions =new List<selectoption>();
displayOptions.add(new selectoption('none','-select-'));
displayOptions.add(new selectoption('10','Next 10 Days'));
displayOptions.add(new selectoption('20','Next 20 Days'));
}}
I want to disable previous date in calendar but its not working.
Log In to reply.
Popular Salesforce Blogs

How You Can Boost Online Grocery Sales? | Salesforce Help Guide
COVID-19 has accelerated the shift to eCommerce and it is more evident than in the grocery category. Online grocery buyers have increased nearly 30 percent…

Unit Testing on Salesforce Lightning Platform | Quick Guide
Before we begin, we have to know about unit testing i.e. what is unit testing and why do we test the code? All that stuff…
Popular Salesforce Videos
See the Future of APIs at Salesforce
Salesforce APIs are a way for other applications (or code in other applications) to programmatically access data within your Salesforce org, in a simple and…
Salesforce For Beginners - Introduction To Salesforce | Salesforce CRM Developement Tutorials
Contents for this Salesforce Training Video: 1:05 - Index 1:31 - What is CRM ? (Customer Relationship Management) 2:17 - What is Salesforce CRM? 3:18…
Non Technical but Want to Build Career in Salesforce?
In this video Shrey gave the answer of the following questions: 1. What is the next step after doing Certification in Salesforce Administrator? 2. How…