title: how validate the primefaces date
body: <p>I have this XHTML code. In this code, the Javascript validation doesnt run:</p>
  
  <pre><code>&lt;h:form id="form1"  &gt;
  
            &lt;h:outputText  for="activity_start_date" value="start date: " /&gt; 
                &lt;p:calendar id="activity_start_date"  navigator="true" mindate="01/01/1950" yearRange="c-50:c+10" value="#{loginBean.activity_start_date}"  onblur="checkdate(this)" widgetVar="from"
              pattern="dd/MM/yyyy" required="true" immediate="true" requiredMessage="Enter start date" /&gt;  
                &lt;h:message for="activity_start_date" style="color:red"/&gt;
  
  
                &lt;h:outputText for="activity_end_date" value="end date: " /&gt; 
                &lt;p:calendar id="activity_end_date"    navigator="true" mindate="01/01/1950" yearRange="c-50:c+10" pattern="dd/MM/yyyy" onblur="checkdate(this)" widgetVar="to"
                value="#{loginBean.activity_end_date}" required="true" immediate="true" requiredMessage="Enter end date"  /&gt;  
                &lt;h:message for="activity_end_date" style="color:red"/&gt;
  </code></pre>
  
  <p></p>
  
  <p>This is my Javascript:</p>
  
  <pre><code>&lt;script  type="text/javascript"&gt;
  function CompareDates()
  {
  
  var str1 = document.getElementById("form1\:activity_start_date").value;
  var str2 = document.getElementById("form1\:activity_end_date").value;
  alert("hai");
  var dt1  = parseInt(str1.substring(0,2),10);
  var mon1 = parseInt(str1.substring(3,5),10);
  var yr1  = parseInt(str1.substring(6,10),10);
  var dt2  = parseInt(str2.substring(0,2),10);
  var mon2 = parseInt(str2.substring(3,5),10);
  var yr2  = parseInt(str2.substring(6,10),10);
  var date1 = new Date(yr1, mon1, dt1);
  var date2 = new Date(yr2, mon2, dt2);
  if(date2 &gt; date1)
  {
      alert("To date cannot be greater than from date");
      return false;
  }
  else
  {
      alert("Submitting ...");
      document.form1.submit();
    }
   }
  &lt;/script&gt;
  </code></pre>
  
  <p>I am using <em>primefaces3.0+jsf</em>. When I press the submit button it goes to the script section, but it doesn't execute body of script. Could you please give me a solution?</p>