-
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
Everything You Need to Know About Salesforce AI Cloud
With the recent emergence of Artificial Intelligence in the market, businesses are so on the front to get their customer interactions to go smarter and…
How to Send and Receive Data from Web Services
Web Services are the best part of Salesforce Development through which one can able to make the code available on the network for use. Through…
CSV Files in Salesforce | Data Import | How-to Guide
Data Import: Clean and Prepare Your Data Using Excel, Data Import: Clean Up Your Import File Learning Objectives Data Import: Clean and Prepare Your Data…
Popular Salesforce Videos
Multi-factor Authentication in Salesforce | Setup of MFA
Multi-factor Authentication in Salesforce: Salesforce offers simple, innovative MFA solutions that provide a balance between strong security and user convenience. Because your business requirements and…
Top 3 Things to See at Dreamforce 2021 | Salesforce
Three things you definitely don't want to miss at Dreamforce this year? ? #DF21 is packed with tons of educational content about your fave Salesforce…
How To Become a Salesforce Developer [Perfect Guide for Beginners]
Curious about a career in Salesforce development? Our video is your concise guide to getting started. What's inside:→ The average salary for a Salesforce Developer…