Wednesday, 8 August 2012

How to disable inputfield at particular day?

VF and APEX Code:
<apex:page controller="disable">
    <apex:form >
    <apex:pageblock title="Input Form">
        <apex:pageBlockSection columns="3">
            <apex:pageBlockSection title="Hyderabd">
                <apex:inputtext disabled="{!lock}"/>                
            </apex:pageBlockSection>
            <apex:pageBlockSection title="Banglore"></apex:pageBlockSection>
            <apex:pageBlockSection title="Chennai"></apex:pageBlockSection>
        </apex:pageBlockSection>
    </apex:pageblock>
    </apex:form>
 
</apex:page>
public class disable {

    public boolean getLock() {
        if(date.today() == date.valueOf('2012-08-08')) {
            return True;
         }
        else {
            return False;
        }
    }
}
Date Method to get day of the week
 In Developer Console:
Datetime dt = DateTime.newInstance(Date.today(), Time.newInstance(0, 0, 0, 0));
String dayOfWeek=dt.format('EEEE');
System.debug('Day : ' + dayOfWeek);
Output:
09:39:41.034|USER_DEBUG|[3]|DEBUG|Day : Tuesday


No comments:

Post a Comment

Labels