+ Start a Discussion
RoyalRoyal 

how to get standard date picker custom VF ?

Hi All,

In custom VF page have to display date fields with date picker, how can i write code for this ?

there is no standard controller, on custom controller is there for page.

Thanks

 
JeeTJeeT
Hi Royal,

Salesforce has a standard vf component called <apex:input> which can help you for this recuirement.
this has type attribute to accept date. 
Ex:
VF:
<apex:input type="date" value="{!x_date}"/>
Apex:
public Date x_date    {get;set;}

Hope this helped you... :)

VineetKumarVineetKumar
Using the <apex:inputField> tag with and object automatically renders the type of that field.
For eg:., if you field is Date/DateTime it will automatically render the date calendar.
<apex:inputField value="{!Object.DateField]" />
For relationship fields, it automatically renders to a lookup field.

Let me know if this helped.
NagendraNagendra (Salesforce Developers) 
Hi Royal,

Please find the below examples to display the date field with date pickers.

Ex 1 :
Visual Force Page :

<apex:page docType="html-5.0" controller="Sample">
<apex:form >
    <apex:pageBlock >
        <apex:pageBlockSection>
            <apex:pageBlockSectionItem>
                Date: <apex:input type="date" value="{!dat}"/>
            </apex:pageBlockSectionItem>
        </apex:pageBlockSection>
    </apex:pageBlock>
</apex:form>
</apex:page>

Apex Controller :
public class Sample {
    public Date dat {get;set;}
    public Sample() {

    }
}

Ex 2 :
Visual Force Page :

<apex:page controller="datePicker" id="mypage">
    <apex:form>    
        Date: <apex:inputText value="{!datename}" size="10" id="demo" onfocus="DatePicker.pickDate(false, this , false);" />    
    </apex:form>
</apex:page>

Apex Controller :
public class DatePicker 
{
    public String datename {get; set;}
}


Note : Before executing the above code check with your visual force page vesion, and set it to 27 - 28 in order for DatePicker to work.

Please mark my solution as best answer if it helps you................

Best Regards,
Nagendra.P
RoyalRoyal
HI Nagendra,

Date: <apex:input type="date" value="{!dat}"/> ------ is not working for IE, Mozila browser.
<apex:inputText value="{!datename}" size="10" id="demo" onfocus="DatePicker.pickDate(false, this , false);" />   ---- is not working for VF page version 37

any other way to acive this ? like by using javascript or Jquery  etc...

Thanks
 
Ankit Gupta SFDCLearnerAnkit Gupta SFDCLearner
Do Simple. If you are getting date or datetime on your controller by actionfunction or actionsupport and your actionfunction or actionsupport is calling under <apex:inputfield>.

use below code:

String sDate = String.ValueOf('DATEGETBYACTIONSUPPORT or DATEGETBYACTIONFUNCTION');

System.Debug('sDate: ' + sDate);