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
jd123jd123 

How to create Date as input with Calendar in visualforce page???

Hi All,

 

  I want to create a date as input with calendar if I enter date value like today date or tomorrow date this date I need get in apex conroller.

 

 Any help is Appreciated.

Best Answer chosen by Admin (Salesforce Developers) 
Navatar_DbSupNavatar_DbSup

Hi,

 

Try the below code snippet as reference:

 

-------- Vf page-------------

<apex:page controller="inputdate" >

<script>

function DynamicDatePicker(d_id)

{

    DatePicker.pickDate(false,d_id.id,false);

}

</script>

  <apex:form >

 

  <apex:inputText id="time" value="{!inputdate}" onfocus="DynamicDatePicker(this);" onchange="checkDateFormatt(this.id);" size="20" disabled="false" style="width:150px;"/>

  <apex:commandButton action="{!testdate}" value="Save" />

  </apex:form>

 

</apex:page>

 

--------------------- Apex Controller --------------------

public class inputdate

{

    public date inputdate{get;set;}

 

 

public void testdate()

{

    system.debug('@@@@@@@@@@@@@@'+inputdate);

}

}

 

Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved. 

All Answers

Navatar_DbSupNavatar_DbSup

Hi,

 

Try the below code snippet as reference:

 

-------- Vf page-------------

<apex:page controller="inputdate" >

<script>

function DynamicDatePicker(d_id)

{

    DatePicker.pickDate(false,d_id.id,false);

}

</script>

  <apex:form >

 

  <apex:inputText id="time" value="{!inputdate}" onfocus="DynamicDatePicker(this);" onchange="checkDateFormatt(this.id);" size="20" disabled="false" style="width:150px;"/>

  <apex:commandButton action="{!testdate}" value="Save" />

  </apex:form>

 

</apex:page>

 

--------------------- Apex Controller --------------------

public class inputdate

{

    public date inputdate{get;set;}

 

 

public void testdate()

{

    system.debug('@@@@@@@@@@@@@@'+inputdate);

}

}

 

Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved. 

This was selected as the best answer
jd123jd123

Great it is working fine.

 

but i need explanation of onfocus and onchange functions  and  DatePicker.pickDate(false,d_id.id,false);


 <apex:inputText id="time" value="{!inputdate}" onfocus="DynamicDatePicker(this);" onchange="checkDateFormatt(this.id);" size="20" disabled="false" style="width:150px;"/>

 

function DynamicDatePicker(d_id)

{

    DatePicker.pickDate(false,d_id.id,false);

}

 

would you please give some explantion. 

Naresh Krishna.ax1176Naresh Krishna.ax1176

Thanks navatar. It works good.

 

How can we disable future dates in date picker ?

Anil MeghnathiAnil Meghnathi

Thanks Ankit

 

Its working.

 

Have a nice day.

 

Anil