I have the following code below. The alert and the output is not working.

<apex:page standardController="Account">
      //Some javascript to handle the datepicker..

      function showDatePicker(thisPtr) {

      DatePicker.pickDate(true, thisPtr.id, false);
   <script type="text/javascript">
      function calculate(){
             var t = document.getElementById("date1").value; 
      if (t != null) {
      var t1= document.getElementById("date2").value;

      t1  = t;

      alert('Please enter the Initial Sign up Date');
   <apex:form  >
      Initial Sign up Date : <input type = "date" onfocus = "showDatePicker(this)"  
      <button onclick="calculate()">GO</button>
      <output type = "date" name="date2"/>
  • Check your browser's JavaScript console for errors. For example there is an unmatched curly bracket in what you have posted.
    – Keith C
    Mar 3, 2016 at 16:55
  • It is still not getting executed
    – DominicSeb
    Mar 3, 2016 at 22:31

1 Answer 1


You are using the DatePicker.pickDate JavaScript function that is part of the Visualforce framework but is not a documented API. A call to this onfocus is one of the results of having a date field in a page but is not the only result; for example the HTML for the date picker is also output. When I run your code I see:

Uncaught TypeError: Cannot read property 'currentStyle' of null

at line 277 of SfdcCore.js perhaps because of that missing HTML or some other implementation detail.

If you need to build something that is different to what Visualforce offers it is safer and more predictable to use a 3rd party library that has a documented API rather than try to reverse engineer the internals of Visualforce.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .