-
Notifications
You must be signed in to change notification settings - Fork 10
/
test.html
41 lines (41 loc) · 1.38 KB
/
test.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
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script>
<script type="text/javascript" src="jquery.numeric.js"></script>
</head>
<body>
<form>
Numbers only:
<input class="numeric" type="text" />
<br/><br/>
Integers only:
<input class="integer" type="text" />
<br/><br/>
No negative values:
<input class="positive" type="text" />
<br/><br/>
No negative values (integer only):
<input class="positive-integer" type="text" />
<br/><br/>
Numbers with up to 2 decimal places:
<input class="decimal-2-places" type="text" />
<br/><br/>
<a href="#" id="remove">Remove numeric</a>
</form>
<script type="text/javascript">
$(".numeric").numeric();
$(".integer").numeric(false, function() { alert("Integers only"); this.value = ""; this.focus(); });
$(".positive").numeric({ negative: false }, function() { alert("No negative values"); this.value = ""; this.focus(); });
$(".positive-integer").numeric({ decimal: false, negative: false }, function() { alert("Positive integers only"); this.value = ""; this.focus(); });
$(".decimal-2-places").numeric({ decimalPlaces: 2 });
$("#remove").click(
function(e)
{
e.preventDefault();
$(".numeric,.integer,.positive,.positive-integer,.decimal-2-places").removeNumeric();
}
);
</script>
</body>
</html>