-
Notifications
You must be signed in to change notification settings - Fork 1
/
example.html
67 lines (55 loc) · 2.57 KB
/
example.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
<!DOCTYPE HTML>
<html>
<head>
<title>jQuery Percent Completion Meter</title>
<style type="text/css">
#container {position:relative; width:990px; margin:0 auto;}
</style>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script>
<script type="text/javascript">
(function($){
$.fn.percentComplete = function(selector, color, size){
return this.each(function(){
var fieldCount = $(selector).not(":radio").length;
var names = [];
$(selector+":radio").each(function(){
var n = $(this).attr('name');
if(names.indexOf(n) < 0){
names.push(n);
}
});
fieldCount = fieldCount + names.length;
if(fieldCount){
var completeCount = $(selector+"[value!='']").not(":checkbox").not(":radio").length + $(selector+":checked").length;
var percentComplete = Math.round((completeCount / fieldCount) * 100);
$(this).empty().append(percentComplete + "% Complete<br><div><div> </div></div>").children("div").css({"width": size, "border": "1px solid"+color}).children("div").css({"width": percentComplete+"%", "background-color":color});
}
});
};
})(jQuery);
$("document").ready(function(){
$("#completion_meter").percentComplete(".required", "#000000", "200px");
$(":input").blur(function(){
$("#completion_meter").percentComplete(".required", "#000000", "200px");
});
});
</script>
</head>
<body>
<div id="container">
<br><br>
<div id="completion_meter"></div>
<br><br>
<form>
<div>First Name: <input class="required" id="first_name" name="first_name" type="text" value=""/></div>
<div>Last Name: <input class="required" id="last_name" name="first_name" type="text" value=""/></div>
<div>Email: <input class="required" id="email" name="email" type="text" value="" /></div>
<div>Birthday: <input class="required" id="Birthday" name="birthday" type="text" value="" /></div>
<div>Address: <input class="required" id="address" name="address" type="text" value="" /></div>
<div>Do you like Tech Crunch: <select class="required" id="tech_crunch"><option value=""></option><option value="yes">yes</option><option value="no">no</option></select></div>
<div>Description:<br><textarea rows="6" cols="40" class="required" name="description" id="description"></textarea></div>
<input type="submit" name="submit" id="submit" value="submit" />
</form>
</div>
</body>
</html>