File: input-number-localization.html

package info (click to toggle)
qtwebkit 2.3.4.dfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 290,116 kB
  • ctags: 272,544
  • sloc: cpp: 1,417,496; python: 85,048; ansic: 39,353; perl: 38,858; ruby: 10,313; objc: 9,505; xml: 8,679; asm: 3,864; yacc: 2,458; sh: 1,237; lex: 813; makefile: 592; java: 228; php: 79
file content (38 lines) | stat: -rw-r--r-- 1,338 bytes parent folder | download | duplicates (15)
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
<!DOCTYPE html>
<html>
<head>
<title>Number type input shows and accepts localized numbers</title>
<style>
:invalid {
  border-color: red;
  -webkit-box-shadow: 4px 4px 8px #ff8888;
}
</style>
</head>
<body>
<div id="console"></div>

<p>Output test 1: The following text field should have a localized representation for "-1234.5678".
e.g. "-1234.5678" for en_US locale, "-1234,5678" for fr_FR locale. The thousand separator is
currently off.</p>
<div><input type=number value="-1234.5678" step=any></div>

<p>Output test 2: The following text field should have "-1234.5678E+12" in any locale.
</p>
<div><input type=number value="-1234.5678E+12" step=any></div>

<p>Input test 1: Type a localized representation of a number (e.g. -1,234.5678 for en_US locale,
-1.234,5678 for fr_FR locale) into the following text field.
You'll see an equivalent number in the standard format on the bottom of the text field.</p>
<p>Input test 2: Type a number in the scientific notation (e.g. 0.1234e-10.)
You'll see the same number string on the bottom of the text field.</p>
<div><input type=number id=target step=any oninput="handleInput()"></div>
<div>Standard format: <output id=output></output></div>

<script>
function handleInput() {
  document.getElementById('output').value = document.getElementById('target').value;
}
</script>
</body>
</html>