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
Saurabh AgrahariSaurabh Agrahari 

Selecting date values only from the date picker

Hi All,

I have inputText component as a date picker in a VF page but the problem with this is user can directly enter a value in the input text component without using the date picker.Is it possible to force user to enter values for the date only from the date picker i.e. in the input text component user should be able to enter values only from the date picker ?
<apex:inputText value="{!startDate}" onfocus="DatePicker.pickDate(false,this,false);" id="startDate" />
Thanks
Saurabh
 
Amit Chaudhary 8Amit Chaudhary 8
Please check below post. I hope that will help you
http://www.infallibletechie.com/2012/11/date-picker-in-visualforce-page.html

Change the visualforce page version to 27 - 28 in order for DatePicker to work
Please let us know if this will help u
Saurabh AgrahariSaurabh Agrahari
Thanks for the reply Amit,

I did the changes as mentioned in the blog you suggested and changed the version to 27 or 28 but the Calender is not showing up.
 
Amit Chaudhary 8Amit Chaudhary 8
Below both Option you tried ?
Visualforce 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;}
}
Visualforce 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() {

    }
}
If yes then please post your full code


 
Saurabh AgrahariSaurabh Agrahari
Option one I am already using but it is having an issue that you can directly enter values in the input text.That is the reason I dont want to use first option.

The code for VF page and Controller is given below:
 
<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>
 
public class Sample {
    public Date dat {get;set;}
    public Sample() {

    }
}

Version Settings:
User-added image