0a01150315d5b65922f53c916e4e7e88fcab088a.svn-base 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
  2. "http://www.w3.org/TR/html4/strict.dtd">
  3. <html>
  4. <head>
  5. <title>Test DateTextBox Widget</title>
  6. <script type="text/javascript" src="../../../dojo/dojo.js"
  7. djConfig="isDebug: true, parseOnLoad: true, extraLocale: ['de-de', 'en-us']"></script>
  8. <script type="text/javascript" src="../_testCommon.js"></script>
  9. <script type="text/javascript">
  10. dojo.require("dijit.form.DateTextBox");
  11. dojo.require("dojo.date.locale");
  12. dojo.require("dojo.parser"); // scan page for widgets and instantiate them
  13. </script>
  14. <style type="text/css">
  15. @import "../../../dojo/resources/dojo.css";
  16. @import "../css/dijitTests.css";
  17. .testExample {
  18. background-color:#fbfbfb;
  19. padding:1em;
  20. margin-bottom:1em;
  21. border:1px solid #bfbfbf;
  22. }
  23. .small {
  24. width: 3em;
  25. }
  26. .medium {
  27. width: 10em;
  28. }
  29. .long {
  30. width: 20em;
  31. }
  32. .verylong {
  33. width: 700px;
  34. }
  35. .noticeMessage {
  36. color:#093669;
  37. font-size:0.95em;
  38. margin-left:0.5em;
  39. }
  40. .dojoTitlePaneLabel label {
  41. font-weight:bold;
  42. }
  43. </style>
  44. </head>
  45. <body>
  46. <h1 class="testTitle">Test DateTextBox Widget</h1>
  47. <!-- to test form submission, you'll need to create an action handler similar to
  48. http://www.utexas.edu/teamweb/cgi-bin/generic.cgi -->
  49. <form id="form1" action="" name="example" method="post">
  50. <div class="dojoTitlePaneLabel">
  51. <label for="q1"> Date (local format) </label>
  52. <span class="noticeMessage">DateTextBox class, no attributes</span>
  53. </div>
  54. <div class="testExample">
  55. <input id="q1" name="noDOMvalue" type="text" dojoType="dijit.form.DateTextBox">
  56. </div>
  57. <div class="dojoTitlePaneLabel">
  58. <label for="q2"> Date (local format - long) </label>
  59. <span class="noticeMessage">DateTextBox class,
  60. Attributes: required="true", trim="true", constraints={min:'2004-01-01',max:'2006-12-31',formatLength:'long'}. Works for leap years</span>
  61. </div>
  62. <div class="testExample">
  63. <input id="q2" type="text" name="date1" class="medium" value="2005-12-30"
  64. dojoType="dijit.form.DateTextBox"
  65. constraints="{min:'2004-01-01',max:'2006-12-31',formatLength:'long'}"
  66. required="true"
  67. trim="true"
  68. promptMessage="mm/dd/yyyy"
  69. onChange="dojo.byId('oc2').value=arguments[0]"
  70. invalidMessage="Invalid date. Use mm/dd/yyyy format." />
  71. onChange:<input id="oc2" size="34" disabled value="not fired yet!" autocomplete="off">
  72. <input type="button" value="Destroy" onClick="dijit.byId('q2').destroy(); return false;">
  73. </div>
  74. <div class="dojoTitlePaneLabel">
  75. <label for="q3"> Date (American format) </label>
  76. <span class="noticeMessage">DateTextBox class,
  77. Attributes: lang="en-us", required="true", constraints={min:'2004-01-01',max:'2006-12-31'}. Works for leap years</span>
  78. </div>
  79. <div class="testExample">
  80. <input id="q3" type="text" name="date2" class="medium" value="2005-12-30"
  81. dojoType="dijit.form.DateTextBox"
  82. constraints="{min:'2004-01-01',max:'2006-12-31'}"
  83. lang="en-us"
  84. required="true"
  85. promptMessage="mm/dd/yyyy"
  86. invalidMessage="Invalid date. Use mm/dd/yyyy format." />
  87. </div>
  88. <div class="dojoTitlePaneLabel">
  89. <label for="q4"> Date (German format) </label>
  90. <span class="noticeMessage">DateTextBox class,
  91. Attributes: lang="de-de", constraints={min:2004-01-01, max:2006-12-31}. Works for leap years</span>
  92. </div>
  93. <div class="testExample">
  94. <input id="q4" class="medium"/>
  95. </div>
  96. <script>
  97. // See if we can make a widget in script and attach it to the DOM ourselves.
  98. dojo.addOnLoad(function(){
  99. var props = {
  100. name: "date4",
  101. value: new Date(2006,10,29),
  102. constraints: {min:new Date(2004,0,1),max:new Date(2006,11,31)},
  103. lang: "de-de",
  104. promptMessage: "dd.mm.yy",
  105. rangeMessage: "Enter a date in 2006.",
  106. invalidMessage: "Invalid date. Use dd.mm.yy format."
  107. };
  108. var w = new dijit.form.DateTextBox(props, "q4");
  109. });
  110. </script>
  111. <script>
  112. function displayData() {
  113. var f = document.getElementById("form1");
  114. var s = "";
  115. for (var i = 0; i < f.elements.length; i++) {
  116. var elem = f.elements[i];
  117. if (elem.name == "button") { continue; }
  118. s += elem.name + ": " + elem.value + "\n";
  119. }
  120. alert(s);
  121. }
  122. </script>
  123. <div>
  124. <button name="button" onclick="displayData(); return false;">view data</button>
  125. <input type="submit" name="submit" />
  126. </div>
  127. </form>
  128. </body>
  129. </html>