7

I'm using <apex:input> tag to display date. It's working fine in Chrome but it's not working in Mozilla.

<apex:input type="date" id="dateid">

4 Answers 4

4

The apex:input component is translated into an HTML input element in the generated HTML. The input type of "date" is not supported in Firefox at this time, whereas it is supported in Chrome.

See: http://caniuse.com/#feat=input-datetime

3
  • 1
    In fact, Chrome seems to have support for more HTML 5 types than any other right now.
    – sfdcfox
    Commented Aug 25, 2014 at 18:38
  • Is their any solution to resolve this issue in Mozilla using apex:input only.
    – user8102
    Commented Aug 26, 2014 at 8:21
  • You could use JavaScript to do feature detection and then provide your own datepicker. Search and you'll find examples such as this one. Commented Aug 26, 2014 at 10:50
2

Try :

<apex:inputField value="{!MyDate}" label="My date :" type="date"/>

See http://www.salesforce.com/us/developer/docs/pages/Content/pages_compref_inputField.htm

4
  • Can we use value attribute in <apex:inputfield> tag with controller fields.I think we can use only fields in object level.
    – user8102
    Commented Aug 26, 2014 at 8:24
  • The value="{!MyDate}" call the getMyDate() controller method. That's what you want to know ?
    – SF_user
    Commented Aug 26, 2014 at 8:28
  • If we use inputfiled value with controoler methods it will gives below error.. Error: Could not resolve the entity from <apex:inputField> value binding '{!mydate1}'. <apex:inputField> can only be used with SObjects, or objects that are Visualforce field component resolvable.
    – user8102
    Commented Aug 26, 2014 at 10:20
  • Yes, your value must return a SObject.
    – SF_user
    Commented Aug 26, 2014 at 10:48
0

I also faced this problem with the and I used the and got the same error which you are getting.

As a workaround what I did is I created an instance of the standard controller record and used its date field as a container to hold the

<apex:inputField value="{InstanceOfObject.AnyDateField}">

This way you will be able to hold the input from the page and use it from the Instance in a controller.

Inside Controller:

ObjectApi InstanceOfObject {get;set;}

Here the Object's Instance will just act as a holder for date inputted from page.

Thank You.

0

You can use a shim/polyfill that will detect whether browser has this feature and will render date picker using Javascript. I had success using this package: nodep-date-input-polyfill.

Just include nodep-date-input-polyfill.dist.js in your Visualforce page and rest will be taken care.

Note that it will look slightly different than native date pickers.

Edit: Here's one more alternative when you need a datepicker but you have no sObject:

<span class="dateInput dateOnlyInput">  
  <apex:inputText id="inputFieldId" size="12" value="{!DateStringProperty}" style="width:72px;text-align:center;" onclick="DatePicker.pickDate(false, this, false);" onfocus="DatePicker.pickDate(false, this, false);"/>  
</span>  

Further outlined here.

You must log in to answer this question.