Description:

In this article, I will explain how to add Datepicker plugin using Jquery.  

Datepicker is used to open an interactive calendar in a small overlay that will choose date for the input fields.

1. Download JqueryUI from http://jqueryui.com/

     2. Extract it and include the files

<script src="jquery-1.10.2.js" type="text/javascript"></script>
<script type="text/javascript" src="jquery-ui-1.10.3.custom.js"></script>
<link href="jquery-ui-1.10.3.custom" rel="Stylesheet" type="text/css" />

     3. Once the document is ready, initialize datepicker widget with the textbox.
        $(document).ready(function () {
            $("#TextBox1").datepicker();
        });

Example program:

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/redmond/jquery-ui.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript"src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
    <script type="text/javascript"src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"></script>
<style type="text/css">
        .ui-datepicker
        {
            font-size8pt;
        }
</style>
    <script type="text/javascript">
        $(function () {
            $("#TextBox1").datepicker({
            showAnim: "slide",
            showButtonPanel: true,
            changeMonth: true,
            changeYear: true,
            dateFormat: "mm/dd/yy"
            });
        });
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
        <asp:Button ID="Button1" runat="server" Text="Button" OnClick="getdata" />
    </div>
    </form>
</body>
</html>


How to use Jquery Datepicker , How to add Datepicker for input field using Jquery , Add Jquery UI Datepicker  for textbox, How to add Jquery UI Datepicker . Add a Datepicker for textbox

0 comments:

Post a Comment

 
Top