Monday, 29 December 2014

Date Picker using java script

<form action="<%=iteratorURL %>" method="post">
<input type="text" name="fromdate" id="fromdate" readonly="readonly" placeholder="From Date"/>
<input type="text" name="todate"  id="todate" readonly="readonly" placeholder="To Date"/>
</form>

<script type="text/javascript">
 $(document).ready(function(){
       $(function() {
       
           $('#fromdate').datepicker({
               minDate: 0,
               dateFormat: 'mm/dd/yy',
                onClose: function (selectedDate) {
                   $("#todate").datepicker("option", "minDate", selectedDate);
               }
           });
           $('#todate').datepicker({
               minDate: 0,
               dateFormat: 'mm/dd/yy'
              
               /* onClose: function (selectedDate) {
                   $("#ExpectedDateStart").datepicker("option", "", selectedDate);
               } */
           });
              
       });
 });
</script>

 IF YOU WANT TO DISPLAY PREVIOUS  DATE ALSO IN FIRST DATE PICKER BOX THEN USE THIS

<script type="text/javascript">
 $(document).ready(function(){
       $(function() {
       
           $('#fromdate').datepicker({
               //minDate: 0,
               dateFormat: 'mm/dd/yy' ,
                onClose: function (selectedDate) {
                   $("#todate").datepicker("option", "minDate", selectedDate);
               }
           });
           $('#todate').datepicker({
               //minDate: 0,
               dateFormat: 'mm/dd/yy'
              
               /* onClose: function (selectedDate) {
                   $("#ExpectedDateStart").datepicker("option", "", selectedDate);
               } */
           });
              
       });
 });
</script> 

No comments: