-
Notifications
You must be signed in to change notification settings - Fork 0
/
2.Forms.html
156 lines (130 loc) · 4.76 KB
/
2.Forms.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
<!DOCTYPE html />
<html>
<head>
<meta charset="utf-8" />
<script type="text/javascript" src="modernizr.js"></script>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.9.1.js"></script>
<style type="text/css">
body {
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
}
form {
width: 300px;
margin: 20px auto;
}
input[type="color"],
input[type="email"],
input[type="range"],
input[type="number"],
input[type="text"],
input[type="url"],
input[type="time"],
input[type="datetime"],
input[type="datetime-local"],
input[type="week"],
input[type="month"] {
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
border: 1px solid #ccc;
font-size: 20px;
width: 300px;
min-height: 30px;
display: block;
margin-bottom: 15px;
margin-top: 5px;
outline: none;
-webkit-border-radius: 4px;
-moz-border-radius: 4px;
-o-border-radius: 4px;
-ms-border-radius: 4px;
border-radius: 4px;
}
input[type='date'] {
margin-bottom: 15px;
margin-top: 5px;
}
input:invalid {
border-color: #e88;
-webkit-box-shadow: 0 0 5px rgba(255, 0, 0, .8);
-moz-box-shadow: 0 0 5px rgba(255, 0, 0, .8);
-o-box-shadow: 0 0 5px rgba(255, 0, 0, .8);
-ms-box-shadow: 0 0 5px rgba(255, 0, 0, .8);
box-shadow:0 0 5px rgba(255, 0, 0, .8);
}
input:required {
border-color: #88a;
-webkit-box-shadow: 0 0 5px rgba(0, 0, 255, .5);
-moz-box-shadow: 0 0 5px rgba(0, 0, 255, .5);
-o-box-shadow: 0 0 5px rgba(0, 0, 255, .5);
-ms-box-shadow: 0 0 5px rgba(0, 0, 255, .5);
box-shadow: 0 0 5px rgba(0, 0, 255, .5);
}
input[type=submit] {
background: none;
padding: 10px;
}
footer {
text-align: right;
}
</style>
<script>
$(function () {
$("#checksupport").bind("mousedown", function(e) {
alert("noes");
if (e.which == 2) {
alert("yupla");
}
});
// Custom client validation
/*$("#email_addr_repeat").change(function (e) {
var email1 = document.getElementById("email_addr");
var email2 = document.getElementById("email_addr_repeat");
if (email1.value !== email2.value) {
email2.setCustomValidity("The two e-mail addresses must match");
}
else {
email2.setCustomValidity("");
}
});*/
// Autofocus fallback
if (!("autofocus" in document.createElement("input"))) {
document.getElementById("full_name").focus();
}
// Add text whether stuff is supported
$("form label[class]").each(function(value, key) {
if (Modernizr.inputtypes[$(this).attr("class")] || Modernizr.input[$(this).attr("class")]) {
$(this).html($(this).text() + " <font size=-2>("+$(this).attr("class")+" supported!)</font>");
} else {
$(this).html($(this).text() + " <font size=-2>("+$(this).attr("class")+" NOT supported!)</font>");
}
});
$("#CurrentRangeValue").click(function() {
alert(document.getElementById("guests").valueAsNumber);
});
});
</script>
</head>
<body>
<form>
<label class="required">Name</label>
<input type="text" id="full_name" name="full_name" placeholder="Jane Doe" required autofocus />
<label class="email">E-mail address</label>
<input type="email" id="email_addr" name="email_addr" />
<label class="color">Room color</label>
<input type="color" id="room_color" name="room_color" />
<label class="date">Arrival date</label>
<input type="date" id="arrival_dt" name="arrival_dt" />
<br><label class="number">Number of nights</label>
<!-- There is also a "step" attribute -->
<input type="number" id="nights" name="nights" value="1" min="1" max="30" />
<label class="range">Number of guests</label> <input type="button" id="CurrentRangeValue" value="Value?">
<input type="range" id="guests" name="guests" value="1" min="1" max="20" />
<label class="pattern">Promo code (6 chars)</label>
<input type="text" id="promo" name="promo" pattern="[A-Za-z0-9]{6}" title="Promo codes consist of 6 alphanumeric characters" />
<input type="submit" value="Submit Reservation" />
</form>
<footer>
<a href="http://miketaylr.com/code/input-type-attr.html" id=checksupport>Check support</a><br>
<a href="3.localStorage.html">More...</a>
</footer>
</body>
</html>