forked from mul14/globalize-example
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
78 lines (67 loc) · 2.16 KB
/
index.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
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
<p>
Culture
<label><input type="radio" name="culture" value="id" checked> Indonesia </label>
<label><input type="radio" name="culture" value="as"> India </label>
<label><input type="radio" name="culture" value="ms"> Malaysia </label>
<label><input type="radio" name="culture" value="en"> United States </label>
</p>
<p class="currency">
Currency
<input type="money" class="input" value="1240000" maxlength="16" />
<span class="output"></span>
</p>
<p class="date">
Date
<input type="date" class="input" value="" />
<span class="output"></span>
</p>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script>
<script src="globalize/lib/globalize.js"></script>
<script src="globalize/lib/cultures/globalize.culture.id.js"></script>
<script src="globalize/lib/cultures/globalize.culture.as.js"></script>
<script src="globalize/lib/cultures/globalize.culture.ms.js"></script>
<script>
// Default culture
Globalize.culture('id');
function init() {
// Init money
money = $('.currency .input').val();
$('.currency .output').text(Globalize.format(parseInt(money), 'c'));
// Today
today = new Date().toJSON().slice(0,10);
$('.date .input').val(today);
output = Globalize.format(new Date(today), "F");
$('.date .output').text(output);
}
$(function(){
init();
$('[name="culture"]').change(function(){
Globalize.culture($(this).val());
init();
console.log(Globalize.culture().name);
})
$('.currency .input').keyup(function(){
value = $(this).val();
if (value != '') {
output = Globalize.format( parseInt(value), "c" );
$(this).siblings('.output').text(output);
} else {
$(this).siblings('.output').text('');
}
})
$('.date .input').change(function(){
value = $(this).val();
output = Globalize.format(new Date(value), "F");
$(this).siblings('.output').text(output);
})
});
</script>
</body>
</html>