-
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 to Hire Salesforce Developers During the 2023 Economic Downturn?
The pressure of economic recession is lurking around and spending on technology is expected to take a downturn. However, when it comes to the Customer…

The Salesforce Schema Builder — What You Need To Know
Keeping the pace of change is a constant challenge for systems and IT teams running Salesforce. Luckily, the platform comes with a ton of built-in…

How DemandBlue Helped Its Customers to Improve Sales and ROI Using Salesforce CPQ Implementation
As a comprehensive and feature-rich platform, Salesforce CPQ is an easy choice for any organization to improve its customers’ buying journey. DemandBlue is an equally…
Popular Salesforce Videos
What is Lookup Relationship in Salesforce?
In this video, Shrey is not only teaching but also demonstrating to you "What is Lookup Relationship in Salesforce?". You will be learning: 1. How…
BradForce Interview with special guest Jason Jung | Landing Your First Salesforce Job
In this video, I have a great conversation with Jason Jung. Jason landed his first Salesforce Job in the middle of a global pandemic. Listen…
AMPscript Lookup - Salesforce Marketing Cloud Functions in 5 minutes
Salesforce Marketing Cloud functions in 5 minutes! In this video, Cameron Robert shows how Lookup() works in Salesforce Marketing Cloud using some helpful visuals to…