[SalesForce] How to create date picker for Dob in salesforce

I want to create a date picker in salesforce in which i can only select date less then today date, i can't select date after today date, how i can achieve this task in salesforce.?

Best Answer

You can do this with jQuery Datepicker set the maxDate property to 0 so that it will disable future dates. Hope this helps.

<apex:page id="myPage" standardController="Contact">
    <link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/themes/smoothness/jquery-ui.css"></link>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
    <script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/jquery-ui.min.js"></script>
    <apex:form id="myForm">
      Select Date: <apex:inputText id="sDate"/>
      <script type="text/javascript">
          var $j = jQuery.noConflict();
              $j("#myPage\\:myForm\\:sDate").datepicker({
                  inline: true,
                  maxDate: 0  
              });
      </script>
    </apex:form>
</apex:page>
Related Topic