-
Notifications
You must be signed in to change notification settings - Fork 0
/
font.html
51 lines (41 loc) · 1.33 KB
/
font.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>jQuery UI Datepicker - Restrict date range</title>
<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" />
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
<link rel="stylesheet" href="/resources/demos/style.css" />
<script>
var curr = new Date; // get current date
var first = curr.getDate() - curr.getDay() + 1; // First day is the day of the month - the day of the week
var last = first + 6; // last day is the first day + 6
var today = new Date(curr);
var firstday = new Date(curr.setDate(first));
var lastday = new Date(curr.setDate(last));
var max = dhm(lastday-today);
var min = dhm(today-firstday);
function dhm(t){
var cd = 24 * 60 * 60 * 1000,
ch = 60 * 60 * 1000,
d = Math.floor(t / cd),
h = '0' + Math.floor( (t - d * cd) / ch),
m = '0' + Math.round( (t - d * cd - h * ch) / 60000);
return [d];
}
$(function() {
$( "#datepicker" ).datepicker({
minDate: "-"+min+"D",
maxDate: "+"+max+"D",
onSelect: function(date){
}
});
});
</script>
</head>
<body>
<p>Date: <input type="text" id="datepicker" /></p>
div.
</body>
</html>