Date Range Picker using the jQuery plugin example


In this article I am going to explain how to use the Date range picker plugin. This is a lightweight jQuery plugin, using this plugin we can choose the following date option in the HTML form elements.
  • Today
  • Last 7 days
  • Month to date
  • Year to date
  • The Previous Month
  • Specific Date
  • All Dates Before
  • All Dates After
  • Date Range


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
        <title>jQuery Date Range Picker Tutorial</title>
        <link rel="stylesheet" href="css/jquery-ui.css" type="text/css" />
        <link rel="stylesheet" href="css/ui.daterangepicker.css" type="text/css" />

        <script type="text/javascript" src="js/jquery.min.js"></script>
        <script type="text/javascript" src="js/jquery-ui.min.js"></script>
        <script type="text/javascript" src="js/date.js"></script>
        <script type="text/javascript" src="js/daterangepicker.jQuery.js"></script>
        <script type="text/javascript"> 
            $(function(){
                $('#range1').daterangepicker(); 
                $('#range2a, #range2b').daterangepicker(); 
                $('#range3').daterangepicker({arrows: true}); 
                $('#range4').daterangepicker(); 
                $('#range5').daterangepicker({constrainDates: true}); 
            });
        </script>

        <!-- from here down, demo-related styles and scripts -->
        <style type="text/css">
            body { font-size: 62.5%; }
            input {width: 196px; height: 1.1em; display:block;}
            h2 { clear: both; padding: 2em 0 0; }
            #range2a,#range2b { float: left; margin-right: 10px; }
        </style>
    </head>
    <body>
      <div style="width: 800px; margin: auto; padding: 30px 60px; border: 1px solid #ccc;">
        <h2>Default Rangepicker</h2> 
        <div>
            <input type="text" value="" id="range1" />   
        </div>

        <h2>2 inputs Rangepicker</h2> 
        <div>
            <input type="text" value="" id="range2a" /> 
            <input type="text" value="" id="range2b" />   
        </div>

        <h2>Rangepicker with arrows</h2> 
        <div>
            <input type="text" value="4/23/99" id="range3" />   
        </div>

        <h2>Rangepicker opening to the right</h2>
        <div style="float: right;">
            <input type="text" value="4/23/99" id="range4" />   
        </div>

        <h2>Rangepicker with contraints</h2>
        <div>
            <input type="text" value="4/23/99" id="range5" />   
        </div>
       </div>
     </body>
</html>

No comments

Powered by Blogger.