| 1 |
<!DOCTYPE HTML> |
| 2 |
<html> |
| 3 |
<head> |
| 4 |
<meta charset="utf-8"> |
| 5 |
<title>Test DateTextBox Widget</title> |
| 6 |
|
| 7 |
|
| 8 |
<link rel="stylesheet" id="themeStyles" href="../../../dijit/themes/tundra/tundra.css"> |
| 9 |
<link rel="stylesheet" href="../../widget/Calendar/Calendar.css"> |
| 10 |
|
| 11 |
<style type="text/css"> |
| 12 |
@import "../../../dojo/resources/dojo.css"; |
| 13 |
@import "../../../dijit/tests/css/dijitTests.css"; |
| 14 |
|
| 15 |
.testExample { |
| 16 |
background-color:#fbfbfb; |
| 17 |
padding:1em; |
| 18 |
margin-bottom:1em; |
| 19 |
border:1px solid #bfbfbf; |
| 20 |
} |
| 21 |
|
| 22 |
body .medium { |
| 23 |
width: 10em; |
| 24 |
} |
| 25 |
|
| 26 |
.noticeMessage { |
| 27 |
color:#093669; |
| 28 |
font-size:0.95em; |
| 29 |
margin-left:0.5em; |
| 30 |
} |
| 31 |
|
| 32 |
.dojoTitlePaneLabel label { |
| 33 |
font-weight:bold; |
| 34 |
} |
| 35 |
</style> |
| 36 |
|
| 37 |
|
| 38 |
<script type="text/javascript" src="../../../dojo/dojo.js" |
| 39 |
data-dojo-config="async:1, parseOnLoad:1, transparentColor: [ 255, 255, 255 ], extraLocale: ['de-de', 'en-us']"></script> |
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
<script type="text/javascript" src="../../../dijit/tests/_testCommon.js"></script> |
| 44 |
</head> |
| 45 |
|
| 46 |
<body class="tundra"> |
| 47 |
<h1 class="testTitle">Test DateTextBox Widget</h1> |
| 48 |
|
| 49 |
|
| 50 |
<form id="form1" data-dojo-type='dijit/form/Form' action="" name="example" method=""> |
| 51 |
<div class="dojoTitlePaneLabel"> |
| 52 |
<label for="q1"> Date (local format) </label> |
| 53 |
<span class="noticeMessage">DateTextBox class, no attributes</span> |
| 54 |
</div> |
| 55 |
<div class="testExample"> |
| 56 |
<input id="q1" name="noDOMvalue" type="text" data-dojo-type="dojox/form/DateTextBox" |
| 57 |
onChange="dojo.byId('oc1').value=arguments[0]" |
| 58 |
> |
| 59 |
onChange:<input id="oc1" size="34" disabled value="not fired yet!" autocomplete="off"> |
| 60 |
</div> |
| 61 |
|
| 62 |
<div class="testExample"> |
| 63 |
Day Only |
| 64 |
<input id="q1Day" name="q1Day" type="text" data-dojo-type="dojox/form/DayTextBox" |
| 65 |
onChange="dojo.byId('oc1day').value=arguments[0]" |
| 66 |
> |
| 67 |
onChange:<input id="oc1day" size="34" disabled value="not fired yet!" autocomplete="off"> |
| 68 |
</div> |
| 69 |
<div class="testExample"> |
| 70 |
Month Only |
| 71 |
<input id="q1Month" name="q1Month" type="text" data-dojo-type="dojox/form/MonthTextBox" |
| 72 |
onChange="dojo.byId('oc1month').value=arguments[0]" |
| 73 |
> |
| 74 |
onChange:<input id="oc1month" size="34" disabled value="not fired yet!" autocomplete="off"> |
| 75 |
</div> |
| 76 |
|
| 77 |
<div class="testExample"> |
| 78 |
Year Only |
| 79 |
<input id="q1Year" name="q1Year" type="text" data-dojo-type="dojox/form/YearTextBox" |
| 80 |
onChange="dojo.byId('oc1year').value=arguments[0]" |
| 81 |
> |
| 82 |
onChange:<input id="oc1year" size="34" disabled value="not fired yet!" autocomplete="off"> |
| 83 |
</div> |
| 84 |
<div class="dojoTitlePaneLabel"> |
| 85 |
<label for="q2"> Date (local format - long) </label> |
| 86 |
<span class="noticeMessage">DateTextBox class, |
| 87 |
Attributes: required="true", trim="true", constraints={min:'2004-01-01',max:'2006-12-31',formatLength:'long'}. Works for leap years</span> |
| 88 |
</div> |
| 89 |
<div class="testExample"> |
| 90 |
<input id="q2" type="text" name="date1" class="medium" value="2005-12-30" |
| 91 |
data-dojo-type="dojox/form/DateTextBox" |
| 92 |
constraints="{min:'2004-01-01',max:'2006-12-31',formatLength:'long'}" |
| 93 |
required="true" |
| 94 |
trim="true" |
| 95 |
onChange="dojo.byId('oc2').value=arguments[0]" |
| 96 |
invalidMessage="Invalid date." /> |
| 97 |
onChange:<input id="oc2" size="34" disabled value="not fired yet!" autocomplete="off"> |
| 98 |
<input type="button" value="Destroy" onClick="dijit.byId('q2').destroy(); return false;"> |
| 99 |
<input type="button" value="set max to 2007-12-31" onClick="dijit.byId('q2').constraints.max = new Date(2007,11,31); return false;"> |
| 100 |
</div> |
| 101 |
<div class="dojoTitlePaneLabel"> |
| 102 |
<label for="q3"> Date (American format) </label> |
| 103 |
<span class="noticeMessage">DateTextBox class, |
| 104 |
Attributes: lang="en-us", required="true", constraints={min:'2004-01-01',max:'2006-12-31'}. Works for leap years</span> |
| 105 |
</div> |
| 106 |
<div class="testExample"> |
| 107 |
<input id="q3" type="text" name="date2" class="medium" value="2005-12-30" |
| 108 |
data-dojo-type="dojox/form/DateTextBox" |
| 109 |
constraints="{min:'2004-01-01',max:'2006-12-31'}" |
| 110 |
lang="en-us" |
| 111 |
required="true" |
| 112 |
promptMessage="mm/dd/yyyy" |
| 113 |
invalidMessage="Invalid date. Use mm/dd/yyyy format." /> |
| 114 |
</div> |
| 115 |
<div class="dojoTitlePaneLabel"> |
| 116 |
<label for="q4"> Date (German format) </label> |
| 117 |
<span class="noticeMessage">DateTextBox class, |
| 118 |
Attributes: lang="de-de", constraints={min:2004-01-01, max:2006-12-31}. Works for leap years</span> |
| 119 |
</div> |
| 120 |
<div class="testExample"> |
| 121 |
<input id="q4" class="medium"/> |
| 122 |
</div> |
| 123 |
|
| 124 |
<div class="dojoTitlePaneLabel"> |
| 125 |
<label for="q5"> Date, overriding pattern</label> |
| 126 |
<span class="noticeMessage">Date, overriding pattern with dd-MM-yyyy</span> |
| 127 |
</div> |
| 128 |
<div class="testExample"> |
| 129 |
<input id="q5" name="noDOMvalue" type="text" data-dojo-type="dojox/form/DateTextBox" data-dojo-props="constraints:{datePattern:'dd-MM-yyyy', strict:true}"> |
| 130 |
</div> |
| 131 |
|
| 132 |
<script> |
| 133 |
// See if we can make a widget in script and attach it to the DOM ourselves. |
| 134 |
require([ |
| 135 |
"dojox/form/DateTextBox", |
| 136 |
"dojo/domReady!" |
| 137 |
], function(DateTextBox){ |
| 138 |
var props = { |
| 139 |
name: "date4", |
| 140 |
value: new Date(2006,10,29), |
| 141 |
constraints: {min:new Date(2004,0,1),max:new Date(2006,11,31)}, |
| 142 |
lang: "de-de", |
| 143 |
promptMessage: "dd.mm.yy", |
| 144 |
rangeMessage: "Enter a date in the year range 2004-2006.", |
| 145 |
invalidMessage: "Invalid date. Use dd.mm.yy format." |
| 146 |
}; |
| 147 |
var w = new DateTextBox(props, "q4"); |
| 148 |
}); |
| 149 |
</script> |
| 150 |
|
| 151 |
<script> |
| 152 |
function displayData() { |
| 153 |
var f = document.getElementById("form1"); |
| 154 |
var s = ""; |
| 155 |
for (var i = 0; i < f.elements.length; i++) { |
| 156 |
var elem = f.elements[i]; |
| 157 |
if (elem.name == "button") { continue; } |
| 158 |
s += elem.name + ": " + elem.value + "\n"; |
| 159 |
} |
| 160 |
alert(s); |
| 161 |
} |
| 162 |
</script> |
| 163 |
|
| 164 |
<div class="dojoTitlePaneLabel"> |
| 165 |
<label for="fromDate"> Date pairs, to/from</label> |
| 166 |
</div> |
| 167 |
<div class="testExample"> |
| 168 |
From: <input id="fromDate" type="text" name="fromDate" data-dojo-type="dojox/form/DateTextBox" |
| 169 |
required="true" |
| 170 |
onChange="dijit.byId('toDate').constraints.min = this.getValue();" /> |
| 171 |
To: <input id="toDate" type="text" name="toDate" data-dojo-type="dojox/form/DateTextBox" |
| 172 |
required="true" |
| 173 |
onChange="dijit.byId('fromDate').constraints.max = this.getValue();" /> |
| 174 |
</div> |
| 175 |
|
| 176 |
<div> |
| 177 |
<button name="button" onclick="displayData(); return false;">view data</button> |
| 178 |
<input type="submit" name="submit" /> |
| 179 |
<input type="reset" name="reset" /> |
| 180 |
</div> |
| 181 |
</form> |
| 182 |
</body> |
| 183 |
</html> |