number.html 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
  2. "http://www.w3.org/TR/html4/strict.dtd">
  3. <html>
  4. <head>
  5. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  6. <title>Test NumberTextBox</title>
  7. <script type="text/javascript" src="../../../dojo/dojo.js"
  8. djConfig="isDebug: true, extraLocale: ['zh-cn','fr-fr','ar-eg','hi-in']"></script>
  9. <script type="text/javascript" src="../../../dojo/currency.js"></script>
  10. <script type="text/javascript" src="../../../dojo/number.js"></script>
  11. <script type="text/javascript">
  12. dojo.require("dijit.form.NumberTextBox");
  13. dojo.require("dijit.form.CurrencyTextBox");
  14. dojo.require("dijit.form.DateTextBox");
  15. dojo.require("dijit.form.ValidationTextBox");
  16. dojo.require("dojo.date.locale");
  17. dojo.require("dojo.date.stamp");
  18. dojo.require("dojo.parser"); // scan page for widgets and instantiate them
  19. dojo.require("doh.runner");
  20. </script>
  21. <script src="test_i18n.js"></script>
  22. <script type="text/javascript">
  23. dojo.addOnLoad(function(){
  24. doh.register("t", getAllTestCases());
  25. doh.run();
  26. });
  27. </script>
  28. <style type="text/css">
  29. @import "../../../dojo/resources/dojo.css";
  30. @import "../../themes/tundra/tundra.css";
  31. @import "../css/dijitTests.css";
  32. .title {
  33. background-color:#ddd;
  34. }
  35. .hint {
  36. background-color:#eee;
  37. }
  38. .testExample {
  39. background-color:#fbfbfb;
  40. padding:1em;
  41. margin-bottom:1em;
  42. border:1px solid #bfbfbf;
  43. }
  44. .dojoTitlePaneLabel label {
  45. font-weight:bold;
  46. }
  47. td {white-space:nowrap}
  48. </style>
  49. </head>
  50. <body class="tundra">
  51. <h1 class="testTitle">Dijit TextBox Globalization Test for Number</h1>
  52. <!-- <h2 class="testTitle">Press the following button to start all test after this page is loaded.</h2>
  53. <button id="startButton" onclick="startTest()">Start Test</button>-->
  54. <p>
  55. Before start this test, make sure the <b>dojo/cldr/nls</b> contains the data for "zh-cn", "fr-fr", "ar-eg" and "hi-in". If not, convert these CLDR data and put them there.
  56. </p>
  57. <script>
  58. (function() {
  59. genFormatTestCases("Number Format", "dijit.form.NumberTextBox", [
  60. { attrs: {lang: "zh-cn"},
  61. desc: "Locale: zh_CN",
  62. value: "12345.067",
  63. expValue: "12,345.067",
  64. comment: ""
  65. },
  66. { attrs: {lang: "zh-cn"},
  67. desc: "Locale: zh_CN",
  68. value: "-12345.067",
  69. expValue: "-12,345.067",
  70. comment: ""
  71. },
  72. { attrs: {lang: "fr-fr"},
  73. desc: "Locale: fr_FR",
  74. value: "12345.067",
  75. expValue: "12&nbsp;345,067",
  76. comment: "Failed in IE. The currency textbox should not reject the value generated by itself. <a href='currency.html#cmt_1'>See #1 (currency.html).</a>"
  77. },
  78. { attrs: {lang: "fr-fr"},
  79. desc: "Locale: zh_CN",
  80. value: "-12345.067",
  81. expValue: "-12&nbsp;345,067",
  82. comment: "Failed in IE. The currency textbox should not reject the value generated by itself. <a href='currency.html#cmt_1'>See #1 (currency.html).</a>"
  83. },
  84. { attrs: {lang: "ar-eg"},
  85. desc: "Locale: ar_EG",
  86. value: "12345.067",
  87. expValue: "12٬345٫067",
  88. comment: ""
  89. },
  90. { attrs: {lang: "ar-eg"},
  91. desc: "Locale: ar_EG",
  92. value: "-12345.067",
  93. expValue: "12٬345٫067-",
  94. comment: ""
  95. },
  96. { attrs: {lang: "ar-eg", constraints: "{localeDigit: true}"},
  97. desc: "Locale: ar_EG",
  98. value: "12345.067",
  99. expValue: "١٢\u066C٣٤٥\u066B٠٦٧",
  100. comment: "<a href='currency.html#cmt_2'>See #2 (currency.html).</a>"
  101. },
  102. { attrs: {lang: "ar-eg", constraints: "{localeDigit: true}"},
  103. desc: "Locale: ar_EG",
  104. value: "-12345.067",
  105. expValue: "١٢\u066C٣٤٥\u066B٠٦٧-",
  106. comment: "<a href='currency.html#cmt_2'>See #2 (currency.html).</a>"
  107. },
  108. { attrs: {lang: "hi-in", constraints: "{localeDigit: true}"},
  109. desc: "Locale: hi_IN",
  110. value: "123456789.068",
  111. expValue: "१२,३४,५६,७८९.०६८",
  112. comment: "<a href='currency.html#cmt_2'>See #2 (currency.html).</a>"
  113. },
  114. { attrs: {lang: "hi-in", constraints: "{localeDigit: true}"},
  115. desc: "Locale: hi_IN",
  116. value: "-123456789.068",
  117. expValue: "-१२,३४,५६,७८९.०६८",
  118. comment: "<a href='currency.html#cmt_2'>See #2 (currency.html).</a>"
  119. }
  120. ]);
  121. genValidateTestCases("Number Validate", "dijit.form.NumberTextBox", [
  122. { attrs: {lang: "zh-cn"},
  123. desc: "Locale: zh_CN",
  124. value: 12345.067,
  125. expValue: "12,345.067",
  126. comment: ""
  127. },
  128. { attrs: {lang: "zh-cn"},
  129. desc: "Locale: zh_CN",
  130. value: -12345.067,
  131. expValue: "-12,345.067",
  132. comment: ""
  133. },
  134. { attrs: {lang: "fr-fr"},
  135. desc: "Locale: fr_FR",
  136. value: 12345.067,
  137. expValue: "12&nbsp;345,067",
  138. comment: "Failed in IE. <a href='currency.html#cmt_1'>See #1 (currency.html).</a>"
  139. },
  140. { attrs: {lang: "fr-fr"},
  141. desc: "Locale: zh_CN",
  142. value: -12345.067,
  143. expValue: "-12&nbsp;345,067",
  144. comment: "Failed in IE. <a href='currency.html#cmt_1'>See #1 (currency.html).</a>"
  145. },
  146. { attrs: {lang: "ar-eg"},
  147. desc: "Locale: ar_EG",
  148. value: 12345.067,
  149. expValue: "12٬345٫067",
  150. comment: ""
  151. },
  152. { attrs: {lang: "ar-eg"},
  153. desc: "Locale: ar_EG",
  154. value: -12345.067,
  155. expValue: "12٬345٫067-",
  156. comment: ""
  157. },
  158. { attrs: {lang: "ar-eg", constraints: "{localeDigit: true}"},
  159. desc: "Locale: ar_EG",
  160. value: 12345.067,
  161. expValue: "١٢\u066C٣٤٥\u066B٠٦٧",
  162. comment: "<a href='currency.html#cmt_2'>See #2 (currency.html).</a>"
  163. },
  164. { attrs: {lang: "ar-eg", constraints: "{localeDigit: true}"},
  165. desc: "Locale: ar_EG",
  166. value: -12345.067,
  167. expValue: "١٢\u066C٣٤٥\u066B٠٦٧-",
  168. comment: "<a href='currency.html#cmt_2'>See #2 (currency.html).</a>"
  169. },
  170. { attrs: {lang: "hi-in", constraints: "{localeDigit: true}"},
  171. desc: "Locale: hi_IN",
  172. value: 123456789.068,
  173. expValue: "१२,३४,५६,७८९.०६८",
  174. comment: "<a href='currency.html#cmt_2'>See #2 (currency.html).</a>"
  175. },
  176. { attrs: {lang: "hi-in", constraints: "{localeDigit: true}"},
  177. desc: "Locale: hi_IN",
  178. value: -123456789.068,
  179. expValue: "-१२,३४,५६,७८९.०६८",
  180. comment: "<a href='currency.html#cmt_2'>See #2 (currency.html).</a>"
  181. }
  182. ]);
  183. dojo.parser.parse();
  184. })();
  185. </script>
  186. </body>
  187. </html>