-
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
The Importance of Salesforce AppExchange for Business Growth | Salesforce AppExchange
Salesforce.com's revolutionary cloud computing marketplace, Salesforce AppExchange, allows businesses to access and install software to meet their specific needs. It was launched in 2005 and is…
Overcoming 5 Biggest Salesforce Integration Challenges
Salesforce is a powerful tool that lets companies create a 360-degree view of their customers and business. Integration with other databases can further enhance the…
Popular Salesforce Videos
Salesforce Checkout: Manage Your Subscription & Buy Licenses
Watch this video to understand how to manage your Salesforce subscription and buy licenses on your own. This makes an easy process even easier, this…
SelectList, select Option & Action Function in Salesforce Apex Language
If you work upon salesforce and VF Pages, you have seen these words one is rendered, reRender, ActionFunction, param, onclick, onchange, In this video, you…
What are Collections in Apex? | Salesforce Development Course
Shrey explained different types of Collections in Apex in this video. Watch the video now and learn, let us know in the comments if you…