-
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
Purpose and Perks of Salesforce Subscription
As a business owner, you know customer relationships are key to success. You also understand that managing those relationships can be time-consuming and expensive. A…
Automate Call Logs Using RingCentral for Salesforce
Hi All, RingCentral one way solution for calling from Salesforce. This app is available on AppExchange, you just need to install it and make some administrator…
9 Tips to Keep Your Data Secure in Salesforce
The increase in remote working and reliance on automation makes many businesses make extra efforts to enhance the Salesforce security. Cybercriminals are on the rise…
Popular Salesforce Videos
Nested Lists in Apex | Salesforce Development Tutorial for Beginners
In this video, Shrey has explained in detail the process to create a Nested List in Apex. Watch the full video to understand. If you…
Salesforce Mobile Publisher Demo
With Salesforce Mobile Publisher, you can create pixel-perfect mobile applications for employees, customers, and partners. Check out this video and learn all you need to…
Welcome to Email Template Builder | Salesforce Learning
In this video, you will learn how to create email templates with Email Template Builder and Email Content Builder. If you have any doubts or…