• #20548
    Salesforce | Atul Atul #167

    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.

    Tagged: , , ,

    #20554
    Salesforce | Nisar Nisar #177

    Please put your script in Document ready method of jquery or use window.onload .

    Ex.

    <script>
    $(document).ready(function() {
    var today = new Date();
    $(“#datepicker”).datepicker({
    changeMonth: true,
    changeYear: true,
    minDate: today
    });
    });
    </script>

    #20555
    Salesforce | Atul Atul #167

    I try this but not working

Viewing 3 posts - 1 through 3 (of 3 total)

Please to reply to this topic.

CONTACT US

We're not around right now. But you can send us an email and we'll get back to you, asap.

Sending

About Us

Forcetalks is a Salesforce collaboration platform for coders & developers, geeks & nerds, consultants & business heads, admins & architects, managers & marketers and of course the business owners. A community where you can learn from, where you can contribute to. For you. For Salesforce. Read More...

Property of Forcetalks.com
Copyright 2017 Forcetalks. All Right Reserved.

Log in with your credentials

or    

Forgot your details?