JavaScript DHTML/jQuery/UI Datepicker
Содержание
- 1 Add image to date picker trigger button
- 2 Create a date picker
- 3 dateFormat:"d MM yy"
- 4 Display a dialog to hold the date picker
- 5 Display two months
- 6 firstDay: 1
- 7 Internationalize date picker
- 8 jQuery UI Datepicker - Display button bar
- 9 jQuery UI Datepicker - Display inline
- 10 jQuery UI Datepicker - Display month and year menus
- 11 jQuery UI Datepicker - Display multiple months
- 12 jQuery UI Datepicker - Format date
- 13 jQuery UI Datepicker - Icon trigger
- 14 jQuery UI Datepicker - Localize calendar
- 15 jQuery UI Datepicker - Populate alternate field
- 16 jQuery UI Datepicker - Restrict date range
- 17 Set date format (appendText: " MM/DD/YYYY")
- 18 Set style for date picker
- 19 Use button to trigger date picker
Add image to date picker trigger button
<html lang="en">
<head>
<title></title>
<link type="text/css" href="js/themes/base/ui.all.css" rel="stylesheet" />
<script type="text/javascript" src="js/jquery-1.3.2.js"></script>
<script type="text/javascript" src="js/ui/ui.core.js"></script>
<script type="text/javascript" src="js/ui/ui.datepicker.js"></script>
<link type="text/css" href="js/demos.css" rel="stylesheet" />
<script type="text/javascript">
$(function() {
var pickerOpts = {
showOn: "button",
buttonImage: "cal.png",
buttonImageOnly: true
};
$("#date").datepicker(pickerOpts);
});
</script>
</head>
<body>
<div class="row"><label>Enter a date: </label><input id="date"></div>
</body>
</html>
Create a date picker
<html lang="en">
<head>
<title></title>
<link type="text/css" href="js/themes/base/ui.all.css" rel="stylesheet" />
<script type="text/javascript" src="js/jquery-1.3.2.js"></script>
<script type="text/javascript" src="js/ui/ui.core.js"></script>
<script type="text/javascript" src="js/ui/ui.datepicker.js"></script>
<link type="text/css" href="js/demos.css" rel="stylesheet" />
<script type="text/javascript">
$(function() {
$("#date").datepicker();
});
</script>
</head>
<body>
<label>Enter a date: </label><input id="date">
</body>
</html>
dateFormat:"d MM yy"
<html lang="en">
<head>
<title></title>
<link type="text/css" href="js/themes/base/ui.all.css" rel="stylesheet" />
<script type="text/javascript" src="js/jquery-1.3.2.js"></script>
<script type="text/javascript" src="js/ui/ui.core.js"></script>
<script type="text/javascript" src="js/ui/ui.datepicker.js"></script>
<link type="text/css" href="js/demos.css" rel="stylesheet" />
<script type="text/javascript">
$(function() {
var pickerOpts = {
dateFormat:"d MM yy"
};
$("#date").datepicker(pickerOpts);
});
</script>
</head>
<body>
<label>Enter a date: </label><input id="date">
</body>
</html>
Display a dialog to hold the date picker
<html lang="en">
<head>
<title></title>
<link type="text/css" href="js/themes/base/ui.all.css" rel="stylesheet" />
<script type="text/javascript" src="js/jquery-1.3.2.js"></script>
<script type="text/javascript" src="js/ui/ui.core.js"></script>
<script type="text/javascript" src="js/ui/ui.datepicker.js"></script>
<link type="text/css" href="js/demos.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>
Display two months
<html lang="en">
<head>
<title></title>
<link type="text/css" href="js/themes/base/ui.all.css" rel="stylesheet" />
<script type="text/javascript" src="js/jquery-1.3.2.js"></script>
<script type="text/javascript" src="js/ui/ui.core.js"></script>
<script type="text/javascript" src="js/ui/ui.datepicker.js"></script>
<link type="text/css" href="js/demos.css" rel="stylesheet" />
<script type="text/javascript">
$(function() {
var pickerOpts = {
numberOfMonths: 2,
stepMonths: 2,
changeMonth: false,
changeYear: false
};
$("#date").datepicker(pickerOpts);
});
</script>
</head>
<body>
<div class="row"><label>Enter a date: </label><input id="date"></div>
</body>
</html>
firstDay: 1
<html>
<head>
<script type="text/javascript" src="js/jquery-1.3.2.js"></script>
<script type="text/javascript" src="js/ui/ui.core.js"></script>
<script type="text/javascript" src="js/ui/ui.datepicker.js"></script>
<script type="text/javascript">
$(document).ready(
function() {
$("input#tmpDate").datepicker({
firstDay: 1
});
}
);
</script>
</head>
<body>
<div>
<label for="tmpDate">Date:</label>
<input type="text" id="tmpDate" size="25" value="" />
</div>
</body>
</html>
Internationalize date picker
<html lang="en">
<head>
<title></title>
<link type="text/css" href="js/themes/base/ui.all.css" rel="stylesheet" />
<script type="text/javascript" src="js/jquery-1.3.2.js"></script>
<script type="text/javascript" src="js/ui/ui.core.js"></script>
<script type="text/javascript" src="js/ui/ui.datepicker.js"></script>
<link type="text/css" href="js/demos.css" rel="stylesheet" />
<script type="text/javascript">
$(function() {
var frenchOpts = {
clearText: "vide",
closeText: "Fin",
currentText: "Courant",
dayNamesMin: [ "Di", "Lu", "Ma", "Me", "Je", "Ve", "Sa" ],
firstDay: 1,
monthNames: [ "Janvier", "Février", "Marche", "Avril", "Pouvez", "Juin", "Juillet", "Août", "Septembre", "Octobre", "Novembre", "Décembre" ],
nextText: "Après",
prevText: "Préc"
};
$("#date").datepicker(frenchOpts);
});
</script>
</head>
<body>
<label>Enter a date: </label><input id="date">
</body>
</html>
jQuery UI Datepicker - Display button bar
<!--
jQuery UI Effects Blind 1.7.2
Copyright (c) 2009 AUTHORS.txt (http://jqueryui.ru/about)
Dual licensed under the MIT (MIT-LICENSE.txt)
and GPL (GPL-LICENSE.txt) licenses.
http://docs.jquery.ru/UI/Effects/Blind
-->
<!doctype html>
<html lang="en">
<head>
<title>jQuery UI Datepicker - Display button bar</title>
<link type="text/css" href="js/themes/base/ui.all.css" rel="stylesheet" />
<script type="text/javascript" src="js/jquery-1.3.2.js"></script>
<script type="text/javascript" src="js/ui/ui.core.js"></script>
<script type="text/javascript" src="js/ui/ui.datepicker.js"></script>
<link type="text/css" href="js/demos.css" rel="stylesheet" />
<script type="text/javascript">
$(function() {
$("#datepicker").datepicker({
showButtonPanel: true
});
});
</script>
</head>
<body>
<div class="demo">
<p>Date: <input type="text" id="datepicker"></p>
</div><!-- End demo -->
<div class="demo-description">
<p>Display a button for selecting Today"s date and a Done button for closing the calendar with the boolean <code>showButtonPanel</code> option. Each button is enabled by default when the bar is displayed, but can be turned off with additional options. Button text is customizable.</p>
</div><!-- End demo-description -->
</body>
</html>
jQuery UI Datepicker - Display inline
<!--
jQuery UI Effects Blind 1.7.2
Copyright (c) 2009 AUTHORS.txt (http://jqueryui.ru/about)
Dual licensed under the MIT (MIT-LICENSE.txt)
and GPL (GPL-LICENSE.txt) licenses.
http://docs.jquery.ru/UI/Effects/Blind
-->
<!doctype html>
<html lang="en">
<head>
<title>jQuery UI Datepicker - Display inline</title>
<link type="text/css" href="js/themes/base/ui.all.css" rel="stylesheet" />
<script type="text/javascript" src="js/jquery-1.3.2.js"></script>
<script type="text/javascript" src="js/ui/ui.core.js"></script>
<script type="text/javascript" src="js/ui/ui.datepicker.js"></script>
<link type="text/css" href="js/demos.css" rel="stylesheet" />
<script type="text/javascript">
$(function() {
$("#datepicker").datepicker();
});
</script>
</head>
<body>
<div class="demo">
Date: <div id="datepicker"></div>
</div><!-- End demo -->
<div class="demo-description">
<p>Display the datepicker embedded in the page instead of in an overlay. Simply call .datepicker() on a div instead of an input.</p>
</div><!-- End demo-description -->
</body>
</html>
<!--
jQuery UI Effects Blind 1.7.2
Copyright (c) 2009 AUTHORS.txt (http://jqueryui.ru/about)
Dual licensed under the MIT (MIT-LICENSE.txt)
and GPL (GPL-LICENSE.txt) licenses.
http://docs.jquery.ru/UI/Effects/Blind
-->
<!doctype html>
<html lang="en">
<head>
<title>jQuery UI Datepicker - Display month & year menus</title>
<link type="text/css" href="js/themes/base/ui.all.css" rel="stylesheet" />
<script type="text/javascript" src="js/jquery-1.3.2.js"></script>
<script type="text/javascript" src="js/ui/ui.core.js"></script>
<script type="text/javascript" src="js/ui/ui.datepicker.js"></script>
<link type="text/css" href="js/demos.css" rel="stylesheet" />
<script type="text/javascript">
$(function() {
$("#datepicker").datepicker({
changeMonth: true,
changeYear: true
});
});
</script>
</head>
<body>
<div class="demo">
<p>Date: <input type="text" id="datepicker"></p>
</div><!-- End demo -->
<div class="demo-description">
<p>Show month and year dropdowns in place of the static month/year header to facilitate navigation through large timeframes. Add the boolean <code>changeMonth</code> and <code>changeYear</code> options.</p>
</div><!-- End demo-description -->
</body>
</html>
jQuery UI Datepicker - Display multiple months
<!--
jQuery UI Effects Blind 1.7.2
Copyright (c) 2009 AUTHORS.txt (http://jqueryui.ru/about)
Dual licensed under the MIT (MIT-LICENSE.txt)
and GPL (GPL-LICENSE.txt) licenses.
-->
<!doctype html>
<html lang="en">
<head>
<title>jQuery UI Datepicker - Display multiple months</title>
<link type="text/css" href="js/themes/base/ui.all.css" rel="stylesheet" />
<script type="text/javascript" src="js/jquery-1.3.2.js"></script>
<script type="text/javascript" src="js/ui/ui.core.js"></script>
<script type="text/javascript" src="js/ui/ui.datepicker.js"></script>
<link type="text/css" href="js/demos.css" rel="stylesheet" />
<script type="text/javascript">
$(function() {
$("#datepicker").datepicker({
numberOfMonths: 3,
showButtonPanel: true
});
});
</script>
</head>
<body>
<div class="demo">
<p>Date: <input type="text" id="datepicker"></p>
</div><!-- End demo -->
<div class="demo-description">
<p>Set the <code>numberOfMonths</code> option to an integer of 2 or more to show multiple months in a single datepicker.</p>
</div><!-- End demo-description -->
</body>
</html>
jQuery UI Datepicker - Format date
<!--
jQuery UI Effects Blind 1.7.2
Copyright (c) 2009 AUTHORS.txt (http://jqueryui.ru/about)
Dual licensed under the MIT (MIT-LICENSE.txt)
and GPL (GPL-LICENSE.txt) licenses.
http://docs.jquery.ru/UI/Effects/Blind
-->
<!doctype html>
<html lang="en">
<head>
<title>jQuery UI Datepicker - Format date</title>
<link type="text/css" href="js/themes/base/ui.all.css" rel="stylesheet" />
<script type="text/javascript" src="js/jquery-1.3.2.js"></script>
<script type="text/javascript" src="js/ui/ui.core.js"></script>
<script type="text/javascript" src="js/ui/ui.datepicker.js"></script>
<link type="text/css" href="js/demos.css" rel="stylesheet" />
<script type="text/javascript">
$(function() {
$("#datepicker").datepicker();
$("#format").change(function() { $("#datepicker").datepicker("option", {dateFormat: $(this).val()}); });
});
</script>
</head>
<body>
<div class="demo">
<p>Date: <input type="text" id="datepicker" size="30"/></p>
<p>Format options:<br />
<select id="format">
<option value="mm/dd/yy">Default - mm/dd/yy</option>
<option value="yy-mm-dd">ISO 8601 - yy-mm-dd</option>
<option value="d M, y">Short - d M, yy</option>
<option value="d MM, y">Medium - d MM, yy</option>
<option value="DD, d MM, yy">Full - DD, d MM, yy</option>
<option value=""day" d "of" MM "in the year" yy">With text - "day" d "of" MM "in the year" yy</option>
</select>
</p>
</div><!-- End demo -->
<div class="demo-description">
<p>Display date feedback in a variety of ways. Choose a date format from the dropdown, then click on the input and select a date to see it in that format.</p>
</div><!-- End demo-description -->
</body>
</html>
jQuery UI Datepicker - Icon trigger
<!--
jQuery UI Effects Blind 1.7.2
Copyright (c) 2009 AUTHORS.txt (http://jqueryui.ru/about)
Dual licensed under the MIT (MIT-LICENSE.txt)
and GPL (GPL-LICENSE.txt) licenses.
http://docs.jquery.ru/UI/Effects/Blind
-->
<!doctype html>
<html lang="en">
<head>
<title>jQuery UI Datepicker - Icon trigger</title>
<link type="text/css" href="js/themes/base/ui.all.css" rel="stylesheet" />
<script type="text/javascript" src="js/jquery-1.3.2.js"></script>
<script type="text/javascript" src="js/ui/ui.core.js"></script>
<script type="text/javascript" src="js/ui/ui.datepicker.js"></script>
<link type="text/css" href="js/demos.css" rel="stylesheet" />
<script type="text/javascript">
$(function() {
$("#datepicker").datepicker({showOn: "button", buttonImage: "images/calendar.gif", buttonImageOnly: true});
});
</script>
</head>
<body>
<div class="demo">
<p>Date: <input type="text" id="datepicker"></p>
</div><!-- End demo -->
<div class="demo-description">
<p>Click the icon next to the input field to show the datepicker. Set the datepicker to open on focus (default behavior), on icon click, or both.</p>
</div><!-- End demo-description -->
</body>
</html>
jQuery UI Datepicker - Localize calendar
<!--
jQuery UI Effects Blind 1.7.2
Copyright (c) 2009 AUTHORS.txt (http://jqueryui.ru/about)
Dual licensed under the MIT (MIT-LICENSE.txt)
and GPL (GPL-LICENSE.txt) licenses.
http://docs.jquery.ru/UI/Effects/Blind
-->
<!doctype html>
<html lang="en">
<head>
<title>jQuery UI Datepicker - Localize calendar</title>
<link type="text/css" href="js/themes/base/ui.all.css" rel="stylesheet" />
<script type="text/javascript" src="js/jquery-1.3.2.js"></script>
<script type="text/javascript" src="js/ui/ui.core.js"></script>
<script type="text/javascript" src="js/ui/ui.datepicker.js"></script>
<script type="text/javascript" src="js/ui/i18n/ui.datepicker-ar.js"></script>
<script type="text/javascript" src="js/ui/i18n/ui.datepicker-bg.js"></script>
<script type="text/javascript" src="js/ui/i18n/ui.datepicker-ca.js"></script>
<script type="text/javascript" src="js/ui/i18n/ui.datepicker-cs.js"></script>
<script type="text/javascript" src="js/ui/i18n/ui.datepicker-da.js"></script>
<script type="text/javascript" src="js/ui/i18n/ui.datepicker-de.js"></script>
<script type="text/javascript" src="js/ui/i18n/ui.datepicker-el.js"></script>
<script type="text/javascript" src="js/ui/i18n/ui.datepicker-eo.js"></script>
<script type="text/javascript" src="js/ui/i18n/ui.datepicker-es.js"></script>
<script type="text/javascript" src="js/ui/i18n/ui.datepicker-fa.js"></script>
<script type="text/javascript" src="js/ui/i18n/ui.datepicker-fi.js"></script>
<script type="text/javascript" src="js/ui/i18n/ui.datepicker-fr.js"></script>
<script type="text/javascript" src="js/ui/i18n/ui.datepicker-he.js"></script>
<script type="text/javascript" src="js/ui/i18n/ui.datepicker-hr.js"></script>
<script type="text/javascript" src="js/ui/i18n/ui.datepicker-hu.js"></script>
<script type="text/javascript" src="js/ui/i18n/ui.datepicker-hy.js"></script>
<script type="text/javascript" src="js/ui/i18n/ui.datepicker-id.js"></script>
<script type="text/javascript" src="js/ui/i18n/ui.datepicker-is.js"></script>
<script type="text/javascript" src="js/ui/i18n/ui.datepicker-it.js"></script>
<script type="text/javascript" src="js/ui/i18n/ui.datepicker-ja.js"></script>
<script type="text/javascript" src="js/ui/i18n/ui.datepicker-ko.js"></script>
<script type="text/javascript" src="js/ui/i18n/ui.datepicker-lt.js"></script>
<script type="text/javascript" src="js/ui/i18n/ui.datepicker-lv.js"></script>
<script type="text/javascript" src="js/ui/i18n/ui.datepicker-ms.js"></script>
<script type="text/javascript" src="js/ui/i18n/ui.datepicker-nl.js"></script>
<script type="text/javascript" src="js/ui/i18n/ui.datepicker-no.js"></script>
<script type="text/javascript" src="js/ui/i18n/ui.datepicker-pl.js"></script>
<script type="text/javascript" src="js/ui/i18n/ui.datepicker-pt-BR.js"></script>
<script type="text/javascript" src="js/ui/i18n/ui.datepicker-ro.js"></script>
<script type="text/javascript" src="js/ui/i18n/ui.datepicker-ru.js"></script>
<script type="text/javascript" src="js/ui/i18n/ui.datepicker-sk.js"></script>
<script type="text/javascript" src="js/ui/i18n/ui.datepicker-sl.js"></script>
<script type="text/javascript" src="js/ui/i18n/ui.datepicker-sq.js"></script>
<script type="text/javascript" src="js/ui/i18n/ui.datepicker-sr.js"></script>
<script type="text/javascript" src="js/ui/i18n/ui.datepicker-sr-SR.js"></script>
<script type="text/javascript" src="js/ui/i18n/ui.datepicker-sv.js"></script>
<script type="text/javascript" src="js/ui/i18n/ui.datepicker-th.js"></script>
<script type="text/javascript" src="js/ui/i18n/ui.datepicker-tr.js"></script>
<script type="text/javascript" src="js/ui/i18n/ui.datepicker-uk.js"></script>
<script type="text/javascript" src="js/ui/i18n/ui.datepicker-zh-CN.js"></script>
<script type="text/javascript" src="js/ui/i18n/ui.datepicker-zh-TW.js"></script>
<link type="text/css" href="js/demos.css" rel="stylesheet" />
<script type="text/javascript">
$(function() {
$.datepicker.setDefaults($.extend({showMonthAfterYear: false}, $.datepicker.regional[""]));
$("#datepicker").datepicker($.datepicker.regional["fr"]);
$("#locale").change(function() {
$("#datepicker").datepicker("option", $.extend({showMonthAfterYear: false},
$.datepicker.regional[$(this).val()]));
});
});
</script>
</head>
<body>
<div class="demo">
<p>Date: <input type="text" id="datepicker"/>
<select id="locale">
<option value="sq">Albanian (Gjuha shqipe)</option>
<option value="ar">Arabic (‫(لعربي</option>
<option value="hy">Armenian (Հայերեն)</option>
<option value="bg">Bulgarian (български език)</option>
<option value="ca">Catalan (Català)</option>
<option value="zh-CN">Chinese Simplified (简体中文)</option>
<option value="zh-TW">Chinese Traditional (繁體中文)</option>
<option value="hr">Croatian (Hrvatski jezik)</option>
<option value="cs">Czech (Ceötina)</option>
<option value="da">Danish (Dansk)</option>
<option value="nl">Dutch (Nederlands)</option>
<option value="eo">Esperanto</option>
<option value="fa">Farsi/Persian (‫(فارسی</option>
<option value="fi">Finnish (suomi)</option>
<option value="fr" selected="selected">French (Français)</option>
<option value="de">German (Deutsch)</option>
<option value="el">Greek (Ελληνικά)</option>
<option value="he">Hebrew (‫(עברית</option>
<option value="hu">Hungarian (Magyar)</option>
<option value="is">Icelandic (Õslenska)</option>
<option value="id">Indonesian (Bahasa Indonesia)</option>
<option value="it">Italian (Italiano)</option>
<option value="ja">Japanese (日本語)</option>
<option value="ko">Korean (한국어)</option>
<option value="lv">Latvian (Latvieöu Valoda)</option>
<option value="lt">Lithuanian (lietuviu kalba)</option>
<option value="ms">Malaysian (Bahasa Malaysia)</option>
<option value="no">Norwegian (Norsk)</option>
<option value="pl">Polish (Polski)</option>
<option value="pt-BR">Portuguese/Brazilian (Português)</option>
<option value="ro">Romanian (Română)</option>
<option value="ru">Russian (Русский)</option>
<option value="sr">Serbian (српски језик)</option>
<option value="sr-SR">Serbian (srpski jezik)</option>
<option value="sk">Slovak (Slovencina)</option>
<option value="sl">Slovenian (Slovenski Jezik)</option>
<option value="es">Spanish (Español)</option>
<option value="sv">Swedish (Svenska)</option>
<option value="th">Thai (ภาษาไทย)</option>
<option value="tr">Turkish (Türkçe)</option>
<option value="uk">Ukranian (Українська)</option>
</select></p>
</div><!-- End demo -->
<div class="demo-description">
<p>Localize the datepicker calendar language and format (English / Western formatting is the default). The datepicker includes built-in support for languages that read right-to-left, such as Arabic and Hebrew.</p>
</div><!-- End demo-description -->
</body>
</html>
jQuery UI Datepicker - Populate alternate field
<!--
jQuery UI Effects Blind 1.7.2
Copyright (c) 2009 AUTHORS.txt (http://jqueryui.ru/about)
Dual licensed under the MIT (MIT-LICENSE.txt)
and GPL (GPL-LICENSE.txt) licenses.
http://docs.jquery.ru/UI/Effects/Blind
-->
<!doctype html>
<html lang="en">
<head>
<title>jQuery UI Datepicker - Populate alternate field</title>
<link type="text/css" href="js/themes/base/ui.all.css" rel="stylesheet" />
<script type="text/javascript" src="js/jquery-1.3.2.js"></script>
<script type="text/javascript" src="js/ui/ui.core.js"></script>
<script type="text/javascript" src="js/ui/ui.datepicker.js"></script>
<link type="text/css" href="js/demos.css" rel="stylesheet" />
<script type="text/javascript">
$(function() {
$("#datepicker").datepicker({altField: "#alternate", altFormat: "DD, d MM, yy"});
});
</script>
</head>
<body>
<div class="demo">
<p>Date: <input type="text" id="datepicker"> <input type="text" id="alternate" size="30"/></p>
</div><!-- End demo -->
<div class="demo-description">
<p>Populate an alternate field with its own date format whenever a date is selected using the <code>altField</code> and <code>altFormat</code> options. This feature could be used to present a human-friendly date for user selection, while passing a more computer-friendly date through for further processing.</p>
</div><!-- End demo-description -->
</body>
</html>
jQuery UI Datepicker - Restrict date range
<!--
jQuery UI Effects Blind 1.7.2
Copyright (c) 2009 AUTHORS.txt (http://jqueryui.ru/about)
Dual licensed under the MIT (MIT-LICENSE.txt)
and GPL (GPL-LICENSE.txt) licenses.
-->
<!doctype html>
<html lang="en">
<head>
<title>jQuery UI Datepicker - Restrict date range</title>
<link type="text/css" href="js/themes/base/ui.all.css" rel="stylesheet" />
<script type="text/javascript" src="js/jquery-1.3.2.js"></script>
<script type="text/javascript" src="js/ui/ui.core.js"></script>
<script type="text/javascript" src="js/ui/ui.datepicker.js"></script>
<link type="text/css" href="js/demos.css" rel="stylesheet" />
<script type="text/javascript">
$(function() {
$("#datepicker").datepicker({minDate: -20, maxDate: "+1M +10D"});
});
</script>
</head>
<body>
<div class="demo">
<p>Date: <input type="text" id="datepicker"></p>
</div><!-- End demo -->
<div class="demo-description">
<p>Restrict the range of selectable dates with the <code>minDate</code> and <code>maxDate</code> options. Set the beginning and end dates as actual dates (new Date(2009, 1 - 1, 26)), as a numeric offset from today (-20), or as a string of periods and units ("+1M +10D"). For the last, use "D" for days, "W" for weeks, "M" for months, or "Y" for years.</p>
</div><!-- End demo-description -->
</body>
</html>
Set date format (appendText: " MM/DD/YYYY")
<html lang="en">
<head>
<title></title>
<link type="text/css" href="js/themes/base/ui.all.css" rel="stylesheet" />
<script type="text/javascript" src="js/jquery-1.3.2.js"></script>
<script type="text/javascript" src="js/ui/ui.core.js"></script>
<script type="text/javascript" src="js/ui/ui.datepicker.js"></script>
<link type="text/css" href="js/demos.css" rel="stylesheet" />
<script type="text/javascript">
$(function() {
var pickerOpts = {
appendText: " MM/DD/YYYY",
changeFirstDay: false,
changeMonth: false,
changeYear: false,
closeAtTop: false,
showOtherMonths: true,
showStatus: true,
showWeeks: true,
duration: "fast"
};
$("#date").datepicker(pickerOpts);
});
</script>
</head>
<body>
<label>Enter a date: </label><input id="date">
</body>
</html>
Set style for date picker
<html>
<head>
<script type="text/javascript" src="js/jquery-1.3.2.js"></script>
<script type="text/javascript" src="js/ui/ui.core.js"></script>
<script type="text/javascript" src="js/ui/ui.datepicker.js"></script>
<script type="text/javascript">
$(document).ready(
function() {
$("input#tmpDate").datepicker({
minDate: new Date(2008, 0, 1),
maxDate: new Date(2009, 0, 1)
});
}
);
</script>
<style type="text/css">
#ui-datepicker-div {
width: 300px;
border: 1px solid rgb(128, 128, 128);
padding: 5px;
background: gray;
display: none;
}
div.ui-datepicker-control {
position: relative;
height: 25px;
background: forestgreen;
}
div.ui-datepicker-control div {
padding: 5px;
}
div.ui-datepicker-control div a {
color: #fff;
}
div.ui-datepicker-links {
position: relative;
height: 20px;
padding: 5px 0 0 0;
background: darkgreen;
border-bottom: 1px solid green;
text-align: center;
}
div.ui-datepicker-links div {
padding: 5px;
}
div.ui-datepicker-links div a {
color: #fff;
}
div.ui-datepicker-clear,
div.ui-datepicker-prev {
position: absolute;
top: 0;
left: 0;
}
div.ui-datepicker-close,
div.ui-datepicker-next {
position: absolute;
top: 0;
right: 0;
}
div.ui-datepicker-current {
display: inline;
}
div.ui-datepicker-header {
margin-top: 5px;
text-align: center;
}
div.ui-datepicker-header select {
margin: 0 3px;
}
table.ui-datepicker {
width: 250px;
border-collapse: collapse;
margin: 10px 0 0 0;
}
table.ui-datepicker td {
padding: 3px;
border: 1px solid red;
}
table.ui-datepicker thead td {
text-align: center;
font-weight: bold;
background: green;
color: lightgreen;
}
td.ui-datepicker-today {
background: #dff6e4;
}
td.ui-datepicker-current-day {
background: darkgreen;
color: #fff;
}
</style>
</head>
<body>
<div>
<label for="tmpDate">Date:</label>
<input type="text" id="tmpDate" size="25" value="" />
</div>
</body>
</html>
Use button to trigger date picker
<html lang="en">
<head>
<title></title>
<link type="text/css" href="js/themes/base/ui.all.css" rel="stylesheet" />
<script type="text/javascript" src="js/jquery-1.3.2.js"></script>
<script type="text/javascript" src="js/ui/ui.core.js"></script>
<script type="text/javascript" src="js/ui/ui.datepicker.js"></script>
<link type="text/css" href="js/demos.css" rel="stylesheet" />
<script type="text/javascript">
$(function() {
var pickerOpts = {
showOn: "button"
};
//create the date picker
$("#date").datepicker(pickerOpts);
});
</script>
</head>
<body>
<div class="row"><label>Enter a date: </label><input id="date"></div>
</body>
</html>