function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Abhishek KedariAbhishek Kedari 

Show datepicker on visualforce page

Hi All,

   How to use datepicker on visualforcepage ?
   I tried different codes avialble on internet but it is either not showing calendar else gives error while saving page itself i.e.  "Error: Component <apex:input> in '/apex/samplePage' requires HTML docType version 5.0 or higher in samplePage at line 16 column 82"
  I want to run it on my current settings.

Can anyone please help me ?

Tried code : 
1) public Date datename { get; set; }

    <apex:input label="datePicker" value="{! datename }" type="auto"/>

2) public String datename { get; set; }

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


If that datepicker field is referencing a Date field, then use <apex:inputField>
Abhishek KedariAbhishek Kedari
When I do that, it gived me this error :

Error: Could not resolve the entity from <apex:inputField> value binding '{!datename}'. <apex:inputField> can only be used with SObjects, or objects that are Visualforce field component resolvable.

Code :

public class SampleClass {

    public Date datename { get; set; }

<apex:inputField label="Date" value="{!datename}"/>

Your datefield is not an SObject field. So you can't use <apex:inputField>. You can use <input> tag instead and render a date picker control using libraries such as JQueryUI.
Here is an example (" target="_blank) if you want to use JQueryUI.
Raja Bipin Chandra  M BRaja Bipin Chandra M B
Try this 

<apex:input value="{!myDateVar}" type="date"/>

It should work! 


Jayant Kumar JaiswalJayant Kumar Jaiswal
Add docType tag to your page as below:

<apex:page docType="html-5.0">

Good Luck