Display a dialog to hold the date picker in JavaScript

Description

The following code shows how to display a dialog to hold the date picker.

Example


<!--   w w w  .  j  ava  2 s.co m-->

<html lang="en">
<head>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.4/jquery-ui.min.js"></script>
<link type="text/css" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.4/themes/smoothness/jquery-ui.css" rel="stylesheet" />
<script type="text/javascript">
$(function() {

$("#invoke").click(function() {
$("#date").datepicker("dialog", "", updateDate);
function updateDate(date) {
$("#date").val(date);
}
});
});
</script>
</head>
<body>
<div id="row"><label>Enter a date: </label>
<input id="date"><a id="invoke" title="" href="#">Click to open Date Picker Dialog</a></div>
</body>
</html>

Click to view the demo

The code above generates the following result.

Display a dialog to hold the date picker in JavaScript