+ Start a Discussion
Felix van Hove 9Felix van Hove 9 

apex:inputField showDatepicker does not work without use of the standardStylesheet

apex:inputField does not seem to work with datePicker and dateTimePicker, if the SF standardStylesheet is not used. A page with the simple code

<apex:page sidebar="false" showHeader="false" standardStylesheets="false" standardController="Contact">
        <apex:form><apex:inputField showDatepicker="true" value="{!contact.birthdate}"/></apex:form>
</apex:page>

produces Javascript error messages as soon as the input field gets the focus in the rendered page:

Uncaught TypeError: Cannot read property 'currentStyle' of null
    at Object.getStyle (main.js:407)
    at Object.setStyle (main.js:406)
    at iframeShim.setStyle (main.js:1350)
    at DatePicker.hide (main.js:658)
    at HTMLDocument.DatePicker.closeHandler (main.js:646)
getStyle @ main.js:407
setStyle @ main.js:406
setStyle @ main.js:1350
DatePicker.hide @ main.js:658
DatePicker.closeHandler @ main.js:646
Navigated to [...]
main.js:18 Uncaught TypeError: Cannot read property 'addEventListener' of null
    at main.js:18
    at new DatePicker (main.js:646)
    at Function.DatePicker.getDatePicker (main.js:659)
    at Function.DatePicker.pickDate (main.js:660)
    at HTMLInputElement.onfocus (Test:7)
[...]

Is this a bug in Salesforce's Javascript? Or what limitations exist in the use of date and date-time pickers? Or have I missed anything?
Nitesh K.Nitesh K.
//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() {

    }
}
in dat parameter pass your Contact.Birthdate

Let me know if this helps.
Felix van Hove 9Felix van Hove 9
Sorry to say, but the question was referring to apex:inputField. apex:inputField is used to refer to fields of objects and a very different beast than apex:input. Your reply not even excluded standard stylesheets.