forked from andyet/Happy.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
demo.html
46 lines (46 loc) · 1.28 KB
/
demo.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
<!DOCTYPE html>
<html>
<head>
<title>Demo</title>
<script src="test/jquery-1.4.4.min.js"></script>
<script src="happy.js"></script>
<script src="happy.methods.js"></script>
<script>
$(document).ready(function () {
$('#awesomeForm').isHappy({
fields: {
// reference the field you're talking about, probably by `id`
// but you could certainly do $('[name=name]') as well.
'#yourName': {
required: true,
message: 'Might we inquire your name'
},
'#email': {
required: true,
message: 'How are we to reach you sans email??',
test: happy.email // this can be *any* function that returns true or false
}
}
});
});
</script>
<style>
body {
font-family: Helvetica;
}
input {
display: block;
}
.unhappyMessage {
display: block;
}
</style>
</head>
<body>
<form id="awesomeForm" action="/lights/camera" method="post">
<input id="yourName" type="text" name="name" />
<input id="email" type="text" name="email" class="" />
<input type="submit" value="go" />
</form>
</body>
</html>