JS

Integrate the jquery datepicker

Here Laxmikant has explained with an example, how to Integrate the jquery datepicker?

Datepickers in jQuery allow you to enter dates easily and visually. You can also customize the date format and language, restrict the selectable date ranges and add in buttons and other navigation options easily.

jQueryUI provides datepicker() method that creates a datepicker and changes the appearance of HTML elements on a page by adding new CSS classes.

For Integrate the jquery Datepickers must inclide these three files

    1.jquery-ui.css
    2.jquery.min.js
    3.jquery-ui.min.js

you can simply include these link in head text.

 <link rel="stylesheet" href="http://code.jquery.com/ui/1.9.1/themes/base/jquery-ui.css" />
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js"></script> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/jquery-ui.min.js"</script>

CSS code:

<style>
        input[type=text], select {
            width: 20%;
            padding: 12px 20px;
            margin: 8px 0;
            display: inline-block;
            border: 1px solid #ccc;
            border-radius: 4px;
            box-sizing: border-box;
        }
        div {
            border-radius: 5px;
            background-color: #f2f2f2;
            padding: 20px;
        }
    </style>

Integrate the jquery datepicker Code

<!DOCTYPE html>

<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="utf-8" />
    <title></title>
    <link rel="stylesheet" href="http://code.jquery.com/ui/1.9.1/themes/base/jquery-ui.css" />
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js"></script>
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/jquery-ui.min.js"></script>
    <script>
        $(document).ready(function () {
            $('#txtDate').datepicker();
        });
    </script>
    <style>
        input[type=text], select {
            width: 20%;
            padding: 12px 20px;
            margin: 8px 0;
            display: inline-block;
            border: 1px solid #ccc;
            border-radius: 4px;
            box-sizing: border-box;
        }

        div {
            border-radius: 5px;
            background-color: #f2f2f2;
            padding: 20px;
        }
    </style>
</head>
<body>
    <div>
        <label>Select Date</label>
        <input type='text' id='txtDate' placeholder="Click me" />
    </div>
</body>
</html>

Output
integrate-the-jquery-datepicker

integrate-the-jquery-datepicker

integrate-the-jquery-datepicker

Leave a Reply

Your email address will not be published. Required fields are marked *