forked from darrentaytay/jquery-character-counter
-
Notifications
You must be signed in to change notification settings - Fork 1
/
examples.html
167 lines (153 loc) · 4.1 KB
/
examples.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
157
158
159
160
161
162
163
164
165
166
167
<!doctype html>
<html lang="en">
<head>
<style>
.exceeded { color: red; }
textarea { width: 200px; height: 50px; }
</style>
<title>jQuery Character Counter Demo</title>
</head>
<body>
<header role="banner">
<h1>jQuery Character Counter Demo</h1>
</header>
<div class="wrap">
<main role="main">
<section>
<header>
<h2>Examples</h2>
</header>
<p>View the source of this page to see the code for each example below.</p>
<article id="examples">
<div class="example">
<h3>#1 - Default Usage</h3>
<form>
<textarea id="name"></textarea>
</form>
</div>
<div class="example">
<h3>#2 - Multiple Inputs</h3>
<form>
<p>
<textarea class="count_me"></textarea>
</p>
<p>
<textarea class="count_me"></textarea>
</p>
<p>
<textarea class="count_me"></textarea>
</p>
</form>
</div>
<div class="example">
<h3>#3 - Custom Counter Format</h3>
<form>
<p>
<textarea id="custom_format_1"></textarea>
</p>
<p>
<textarea id="custom_format_2"></textarea>
</p>
</form>
</div>
<div class="example">
<h3>#4 - Callbacks</h3>
<form>
<p>
<textarea id="callback"></textarea>
</p>
</form>
</div>
<div class="example">
<h3>#5 - Custom Fields</h3>
<p>Inspect counter element to see custom fields applied.</p>
<p>
<form>
<p>
<textarea id="custom_fields"></textarea>
</p>
</form>
</div>
<div class="example">
<h3>#6 - Counter Selector (<span id="my_counter"></span> characters left)</h3>
<p>Counter could be anywhere on the page.</p>
<p>
<form>
<p>
<textarea id="counter_selector"></textarea>
</p>
</form>
</div>
<div class="example">
<h3>#7 - Multiple Counters</h3>
<form>
<p style="width: 205px;">
<span class="a_counter" style="float: right;"></span>
<textarea id="multiple_counters"></textarea>
<span class="a_counter"></span>
</p>
</div>
</form>
</div>
<div class="example">
<h3>#8 - Min & Max Limit</h3>
<form>
<p>Minimum of 5 characters. Maximum of 25 characters.</p>
<textarea id="min_max_counter"></textarea>
</form>
</div>
</article>
</section>
</main>
</div>
<footer role="contentinfo">
<small>Copyright © <time datetime="2013">2013</time></small>
</footer>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script type="text/javascript" src="jquery.charactercounter.js"></script>
<script>
$(function(){
//Example #1
$("#name").characterCounter({});
//Example #2
$(".count_me").characterCounter();
//Example #3
$("#custom_format_1").characterCounter({
counterFormat: '%1 characters remaining.'
});
$("#custom_format_2").characterCounter({
counterFormat: 'Characters Remaining: %1'
});
//Example #4
$("#callback").characterCounter({
onExceed: function(){
alert("Limit exceeded.");
},
onDeceed: function(){
alert("Limit deceeded.");
}
});
//Exampe #5
$("#custom_fields").characterCounter({
customFields: {
'class': 'test this class',
'data-id': 'custom-field-example'
}
});
//Example #6
$("#counter_selector").characterCounter({
counterSelector: '#my_counter'
});
//Example #6
$("#multiple_counters").characterCounter({
counterSelector: '.a_counter'
});
//Example #6
$("#min_max_counter").characterCounter({
min: 5,
limit: 25
});
});
</script>
</body>
</html>