Debian Codegraph @

dijit/tests/form/Form.html

raw symbols SCIP
1 <!DOCTYPE html>
2 <html lang="en">
3 <head>
4
5 <meta http-equiv="Content-type" content="text/html; charset=utf-8">
6
7 <title>Form unit test</title>
8 <style type="text/css">
9 @import "../../themes/claro/document.css";
10 @import "../css/dijitTests.css";
11 TD { border:2px outset; padding:2px; }
12 TH { border:2px solid; font-weight: bold; padding:1px; }
13 </style>
14
15 <!-- required: the default dijit theme: -->
16 <link id="themeStyles" rel="stylesheet" href="../../../dijit/themes/claro/claro.css"/>
17
18 <!-- required: dojo.js -->
19 <script type="text/javascript" src="../../../dojo/dojo.js"
20 data-dojo-config="isDebug: true"></script>
21
22 <!-- only needed for alternate theme testing: -->
23 <script type="text/javascript" src="../_testCommon.js"></script>
24
25 <script type="text/javascript">
26 dojo.require("doh.runner");
27 dojo.require("dojo.date");
28 dojo.require("dojo.parser");
29 dojo.require("dijit.dijit"); // optimize: load dijit layer
30 dojo.require("dijit.focus");
31 dojo.require("dijit.form.Form");
32 dojo.require("dijit.layout.ContentPane");
33 dojo.require("dijit.form.ComboBox");
34 dojo.require("dijit.form.CheckBox");
35 dojo.require("dijit.form.RadioButton");
36 dojo.require("dijit.form.DateTextBox");
37 dojo.require("dijit.form.Button");
38 dojo.require("dijit.form.MultiSelect");
39 dojo.require("dijit.form.Select");
40 dojo.require("dijit.form.Textarea");
41 dojo.require("dijit.form.SimpleTextarea");
42 dojo.require("dijit.Editor");
43
44 var obj;
45 function getValues(){
46 obj = dijit.byId('myForm').get('value');
47 console.log("Object is: " + dojo.toJson(obj, true));
48 }
49
50 function setValues(){
51 if(!obj){
52 obj = {testF: 'testi'};
53 }
54 console.log("Object is: " + dojo.toJson(obj, true));
55 dijit.byId('myForm').set('value', obj);
56 }
57
58 function validate(){
59 console.log(dijit.byId('myForm').validate());
60 }
61
62 function defaultSubmitHandler(values){
63 console.log('actual submitted values: ' + dojo.toJson(values));
64 }
65 submittedValues = defaultSubmitHandler;
66 // make dojo.toJson() print dates correctly (this feels a bit dirty)
67 Date.prototype.json = function(){ return dojo.date.stamp.toISOString(this, {selector: 'date'});};
68
69 var d = dojo.date.stamp.fromISOString;
70
71 // These are the values assigned to the widgets in the page's HTML
72 var original = {
73 foo: {bar: {baz: {quux: d("2007-12-30")} } },
74 available: {from: d("2005-01-02"), to: d("2006-01-02")},
75 plop: {combo: "one"},
76 cb: ["2", "3"],
77 r: "2",
78 ms1: ["VA", "WA"],
79 s1: "VA",
80 h1: "hidden",
81 t1: "line 1\nline 2",
82 st1: "simple line 1\nsimple line 2",
83 richtext: "<h1>original</h1><p>This is the default content</p>",
84 filename: "",
85 requiredWidget: "",
86 readOnlyWidget: "Should be returned",
87 duplicate: ["first", "second", "third"]
88 };
89
90 // we change the form to these values
91 var changed = {
92 foo: {bar: {baz: {quux: d("2005-01-01")} } },
93 available: {from: d("2005-11-02"), to: d("2006-11-02")},
94 plop: {combo: "three"},
95 cb: ["4"],
96 r: "1",
97 ms1: ["FL", "CA"],
98 s1: "FL",
99 h1: "still hidden",
100 t1: "new line 1\nnew line 2",
101 st1: "new simple line 1\nnew simple line 2",
102 richtext: "<h1>changed</h1><p>This is the changed content set by set('value', ...')</p>",
103 filename: "",
104 requiredWidget: "abc",
105 readOnlyWidget: "Should be returned",
106 duplicate: ["1", "2", "3"]
107 };
108 var partialChange = {
109 foo: {bar: {baz: {quux: d("2006-01-01")} } },
110 available: {from: d("2006-11-02"), to: d("2007-11-02")},
111 plop: {combo: "two"},
112 cb: ["2"]
113 };
114
115 dojo.ready(function(){
116
117 doh.register("parse", function(){
118 dojo.parser.parse();
119
120 formWidget = dijit.byId("myForm");
121 });
122
123 // should be able to query for all of the inputs, including hidden ones
124 doh.register("query input by checked state", [
125 {
126 name: "all",
127 runTest: function(){
128 var queried=dojo.query("input[checked]");
129 doh.t(queried.length>0,"dojo.query could not find checked widgets.");
130 doh.is(3,queried.length,"expected: 3 checked widgets, got: "+queried.length);
131 doh.is(dojo.byId('cb_2'),queried[0],"Expected 2nd checkbox.");
132 doh.is(dojo.byId('cb_3'),queried[1],"Expected 3rd checkbox.");
133 doh.is(dojo.byId('r_2'),queried[2],"Expected 2nd radio button.");
134 }
135 }
136 ]);
137
138 doh.register("query input by name",
139 dojo.map(
140 [
141 "foo.bar.baz.quux","available.from","available.to", // DateTextBox
142 "plop.combo", // ComboBox
143 "cb", // CheckBox
144 "r", // RadioButton
145 //"ms1", // MultiSelect
146 "h1", // plain hidden input
147 //"t1", "st1", // TextArea
148 //"richtext", // Editor
149 "filename", // TextBox set to file input
150 "disabledWidget" // disabled TextBox
151 ],
152 function(name){
153 return {
154 name: name,
155 widgetName: name,
156 runTest: function(){
157 var queried = dojo.query("input[name="+this.widgetName+"]");
158 doh.t(queried.length > 0, "dojo.query could not find form widget: '"+this.widgetName+"'");
159 }
160 };
161 }
162 )
163 );
164
165 var resetready=false;
166 var testSubmittedValues = function(deferred, testValues, formValues){
167 deferred.getTestCallback(function(){
168 doh.is(testValues.foo.bar.baz.quux.json(), formValues['foo.bar.baz.quux']);
169 doh.is(testValues.available.from.json(), formValues['available.from']);
170 doh.is(testValues.available.to.json(), formValues['available.to']);
171 doh.is(testValues.plop.combo, formValues['plop.combo']);
172 doh.is(testValues.cb, formValues.cb);
173 doh.is(testValues.r, formValues.r);
174 doh.is(testValues.ms1, formValues.ms1);
175 doh.is(testValues.s1, formValues.s1);
176 doh.is(testValues.h1, formValues.h1);
177 doh.is(testValues.t1, formValues.t1);
178 doh.is(testValues.st1, formValues.st1);
179 doh.is(testValues.filename, formValues.filename || '');
180 doh.is(testValues.readOnlyWidget, formValues.readOnlyWidget);
181 })();
182 };
183 doh.register("general tests",
184 [
185 {
186 name: "setUp",
187 timeout: 5000,
188 runTest: function(){
189 var d=new doh.Deferred();
190
191 var defer=function(){
192 if(dijit.byId('t1')._resetValue!==undefined &&
193 !dijit.byId('editor').disabled){
194 doh.t(true);
195 d.callback(true);
196 }else{
197 setTimeout(defer,100);
198 }
199 };
200 setTimeout(defer,1000);
201 return d;
202 }
203 },
204 function getValues(){
205 var values = formWidget.get('value');
206
207 // FF3 sticks in some tabs and newlines that mess up the equality check
208 // Need better way to compare two HTML trees but for now do this.
209 values.richtext = values.richtext.replace(/[\n\t]/, "", "g");
210
211 doh.is( dojo.toJson(original), dojo.toJson(values) );
212 },
213 {
214 name:"testSubmit",
215 timeout: 10000,
216 runTest:function(){
217 var d=new doh.Deferred();
218 submittedValues = function(values){
219 testSubmittedValues(d, original, values);
220 };
221 setTimeout(function(){ formWidget.containerNode.submit(); }, 1000);
222 return d;
223 },
224 tearDown: function(){
225 submittedValues = defaultSubmitHandler;
226 }
227 },
228 function setValues(){
229 formWidget.set('value', changed);
230 doh.is( dojo.toJson(changed), dojo.toJson(formWidget.get('value')) );
231
232 formWidget.set('value', partialChange);
233 doh.is( dojo.toJson(dojo.mixin(changed,partialChange)), dojo.toJson(formWidget.get('value')) );
234 },
235 function nameAttributeSurvived(){ // ticket:4753
236 var radios = dojo.query("INPUT[type=radio]", "radio-cells").forEach(
237 function(r){
238 doh.is( r.name, "r" );
239 });
240 },
241 {
242 name:"postSubmit",
243 timeout:5000,
244 runTest:function(){
245 var d=new doh.Deferred();
246 submittedValues = function(values){
247 testSubmittedValues(d, dojo.mixin(changed,partialChange), values);
248 };
249 setTimeout(function(){ formWidget.containerNode.submit(); }, 1000);
250 return d;
251 },
252 tearDown: function(){
253 submittedValues = defaultSubmitHandler;
254 }
255 },
256 function resetTest(){
257 formWidget._onResetReturn = false;
258 formWidget.reset();
259 doh.isNot( dojo.toJson(original), dojo.toJson(formWidget.get('value')), "onReset false");
260 formWidget._onResetReturn = true;
261 formWidget.reset();
262 delete formWidget._onResetReturn;
263 doh.is( dojo.toJson(original), dojo.toJson(formWidget.get('value')), "onReset true" );
264 }
265 ]
266 );
267
268 doh.register("watch('value')", [
269 // Set() calls fire onChange() on a timer, so set calls from above may have unfired onChange events.
270 // Avoid spurious watch() notifications by waiting for lingering onChange() events to fire.
271 function coolDown(){
272 var d = new doh.Deferred();
273 setTimeout(function(){ d.callback(true); }, 100);
274 return d;
275 },
276
277 // Setup watch("value", ...)
278 function setUp(){
279 // Setup globals to reflect return from watch("value"), ...
280 calls = 0;
281 oldVal = null;
282 newVal = null;
283
284 handle = formWidget.watch("value", function(name, oldV, newV){
285 calls++;
286 oldVal = oldV;
287 newVal = newV;
288 });
289 },
290
291 // Change the DateTextBox values through Form.set("value", ...)
292 // and see if Form.watch("value", ...) does the right thing
293 function formSet(){
294 var d = new doh.Deferred();
295 calls = 0;
296 formWidget.set("value", {
297 foo: {bar: {baz: {quux: "1967-10-20"} } },
298 available: {from: "1967-11-09"}
299 });
300
301 setTimeout(d.getTestCallback(function(){
302 doh.is(1, calls, "exactly one watch(value) call");
303 doh.is('2007-12-30', dojo.date.stamp.toISOString(oldVal.foo.bar.baz.quux, {selector: 'date'}), "old value");
304 doh.is('1967-10-20', dojo.date.stamp.toISOString(newVal.foo.bar.baz.quux, {selector: 'date'}), "new value");
305 doh.is('1967-11-09', dojo.date.stamp.toISOString(newVal.available.from, {selector: 'date'}), "new value2");
306 }), 500);
307
308 return d;
309 },
310
311 // Change the DateTextBox value directly
312 // and see if Form.watch("value", ...) does the right thing
313 function directSet(){
314 var d = new doh.Deferred();
315
316 calls = 0;
317 dijit.byId("dtb1").set("value", "1981-10-12");
318
319 setTimeout(d.getTestCallback(function(){
320 doh.is(1, calls, "exactly one watch(value) call");
321 doh.is('1967-10-20', dojo.date.stamp.toISOString(oldVal.foo.bar.baz.quux, {selector: 'date'}), "old value");
322 doh.is('1981-10-12', dojo.date.stamp.toISOString(newVal.foo.bar.baz.quux, {selector: 'date'}), "new value");
323 }), 500);
324
325 return d;
326 },
327
328 // Change the CheckBox values through Form.set("value", ...)
329 // and see if Form.watch("value", ...) does the right thing
330 function checkboxSet(){
331 var d = new doh.Deferred();
332
333 calls = 0;
334 formWidget.set("value", {cb: ["1", "4"]});
335
336 setTimeout(d.getTestCallback(function(){
337 doh.is(1, calls, "exactly one watch(value) call");
338
339 doh.is(2, oldVal.cb.length, "number of checkboxes previously checked");
340 doh.is(2, oldVal.cb[0], "old checkboxes, first checked");
341 doh.is(3, oldVal.cb[1], "old checkboxes, second checked");
342
343 doh.is(2, newVal.cb.length, "number of checkboxes currently checked");
344 doh.is(1, newVal.cb[0], "new checkboxes, first checked");
345 doh.is(4, newVal.cb[1], "new checkboxes, second checked");
346 }), 500);
347
348 return d;
349 },
350
351 // Uncheck a CheckBox directly
352 // and see if Form.watch("value", ...) does the right thing
353 function directCheckBoxUncheck(){
354 var d = new doh.Deferred();
355
356 calls = 0;
357 dijit.byId("cb_1").set("checked", false);
358
359 setTimeout(d.getTestCallback(function(){
360 doh.is(1, calls, "exactly one watch(value) call");
361
362 doh.is(2, oldVal.cb.length, "number of checkboxes previously checked");
363 doh.is(1, oldVal.cb[0], "old checkboxes, first checked");
364 doh.is(4, oldVal.cb[1], "old checkboxes, second checked");
365
366 doh.is(1, newVal.cb.length, "number of checkboxes currently checked");
367 doh.is(4, newVal.cb[0], "new checkboxes, first checked");
368 }), 500);
369
370 return d;
371 },
372
373 // Check a CheckBox directly
374 // and see if Form.watch("value", ...) does the right thing
375 function directCheckBoxCheck(){
376 var d = new doh.Deferred();
377
378 calls = 0;
379 dijit.byId("cb_2").set("checked", true);
380
381 setTimeout(d.getTestCallback(function(){
382 doh.is(1, calls, "exactly one watch(value) call");
383
384 doh.is(1, oldVal.cb.length, "number of checkboxes previously checked");
385 doh.is(4, oldVal.cb[0], "old checkboxes, first checked");
386
387 // the new array should be [2,4] not [4,2] because the order the checkboxes
388 // were checked shouldn't matter; the value needs to be canonical
389 doh.is(2, newVal.cb.length, "number of checkboxes currently checked");
390 doh.is(2, newVal.cb[0], "new checkboxes, first checked");
391 doh.is(4, newVal.cb[1], "new checkboxes, second checked");
392 }), 500);
393
394 return d;
395 },
396
397 // Change the selected RadioButton through Form.set("value", ...)
398 // and see if Form.watch("value", ...) does the right thing
399 function radioSet(){
400 var d = new doh.Deferred();
401
402 calls = 0;
403 formWidget.set("value", {r: "3"});
404
405 setTimeout(d.getTestCallback(function(){
406 doh.is(1, calls, "exactly one watch(value) call");
407 doh.is(2, oldVal.r, "old selected radio button");
408 doh.is(3, newVal.r, "new selected radio button");
409 }), 500);
410
411 return d;
412 },
413
414 // Change the selected RadioButton directly
415 // and see if Form.watch("value", ...) does the right thing
416 function radioDirectSet(){
417 var d = new doh.Deferred();
418
419 calls = 0;
420 dijit.byId("r_1").set("checked", true);
421
422 setTimeout(d.getTestCallback(function(){
423 doh.is(1, calls, "exactly one watch(value) call");
424 doh.is(3, oldVal.r, "old selected radio button");
425 doh.is(1, newVal.r, "new selected radio button");
426 }), 500);
427
428 return d;
429 },
430
431 // Disabling a widget should remove it from the value
432 function disableWidget(){
433 var d = new doh.Deferred();
434
435 calls = 0;
436 dijit.byId("dtb1").set("disabled", true);
437
438 setTimeout(d.getTestCallback(function(){
439 doh.is(1, calls, "one watch(value) call");
440 doh.t(dojo.getObject("foo.bar.baz.quux", false, oldVal) !== undefined, "attribute used to exist");
441 doh.t(dojo.getObject("foo.bar.baz.quux", false, newVal) === undefined, "attribute no longer exists");
442 }), 500);
443
444 return d;
445 },
446
447 // Enabling a widget should add it back to the value
448 function enableWidget(){
449 var d = new doh.Deferred();
450
451 calls = 0;
452 dijit.byId("dtb1").set("disabled", false);
453
454 setTimeout(d.getTestCallback(function(){
455 doh.is(1, calls, "one watch(value) call");
456 doh.t(dojo.getObject("foo.bar.baz.quux", false, oldVal) === undefined, "attribute didn't used to exist");
457 doh.t(dojo.getObject("foo.bar.baz.quux", false, newVal) !== undefined, "attribute now exists");
458 }), 500);
459
460 return d;
461 },
462
463 function tearDown(){
464 handle.unwatch();
465 }
466 ]);
467
468 doh.register("watch('state')", [
469 // fill in something in required field so that form is valid
470 function makeValid(){
471 doh.f(formWidget.isValid(), "form isn't valid (due to required but empty)");
472 dijit.byId("rw").set("value", "abc");
473 doh.t(formWidget.isValid(), "form is now valid");
474 },
475
476 // Setup watch("state", ...)
477 function setUp(){
478 // Setup globals to reflect return from watch("value"), ...
479 calls = 0;
480 oldVal = null;
481 newVal = null;
482
483 handle = formWidget.watch("state", function(name, oldV, newV){
484 calls++;
485 oldVal = oldV;
486 newVal = newV;
487 });
488
489 validState = true;
490 dojo.connect(formWidget, "onValidStateChange", function(val){
491 validState = val;
492 });
493 },
494
495 // Start typing a value into the DateTextBox while it's focused.
496 // The incomplete value should trigger a change of the Form to Incomplete state even though
497 // user is still focused
498 function partialInput(){
499 var d = new doh.Deferred();
500
501 // Simulate the typing and validation checking since this isn't a robot test
502 dojo.byId("dtb1").focus();
503 dojo.byId("dtb1").value = "12/";
504 dijit.byId("dtb1").validate(true);
505
506 setTimeout(d.getTestCallback(function(){
507 doh.is(1, calls, "one watch(state) calls");
508 doh.is("", oldVal, "old state");
509 doh.is("Incomplete", newVal, "new state");
510 }), 50);
511
512 return d;
513 },
514
515 // Finishing the input will change state back to ""
516 function finishInput(){
517 var d = new doh.Deferred();
518
519 calls = 0;
520
521 // Simulate the typing and validation checking since this isn't a robot test
522 dojo.byId("dtb1").value = "12/31/2012";
523 dijit.byId("dtb1").validate(true);
524
525 setTimeout(d.getTestCallback(function(){
526 doh.is(1, calls, "another watch(state) calls");
527 doh.is("Incomplete", oldVal, "old state");
528 doh.is("", newVal, "new state");
529 }), 50);
530
531 return d;
532 },
533
534 // An error value should trigger the Form.state change, even before blur
535 function errorInput(){
536 var d = new doh.Deferred();
537
538 calls = 0;
539
540 // Simulate the typing and validation checking since this isn't a robot test
541 dojo.byId("dtb1").value = "12/a";
542 dijit.byId("dtb1").validate(true);
543
544 setTimeout(d.getTestCallback(function(){
545 doh.is(1, calls, "another watch(state) call");
546 doh.is("", oldVal, "old state");
547 doh.is("Error", newVal, "new state");
548 doh.f(validState, "onValidStateChange(false) called")
549 }), 50);
550
551 return d;
552 },
553
554 // Disabling the widget in error state should make the form valid
555 function disableErrorWidget(){
556 var d = new doh.Deferred();
557
558 calls = 0;
559 dijit.byId("dtb1").set("disabled", true);
560
561 setTimeout(d.getTestCallback(function(){
562 doh.is(1, calls, "one watch(state) call");
563 doh.is("Error", oldVal, "old state");
564 doh.is("", newVal, "new state");
565 doh.t(formWidget.isValid(), "isValid");
566 }), 50);
567
568 return d;
569 },
570
571 // Enabling the widget in error state should make the form invalid again
572 function enableErrorWidget(){
573 var d = new doh.Deferred();
574
575 calls = 0;
576 dijit.byId("dtb1").set("disabled", false);
577
578 setTimeout(d.getTestCallback(function(){
579 doh.is(1, calls, "one watch(state) call");
580 doh.is("", oldVal, "old state");
581 doh.is("Error", newVal, "new state");
582 doh.f(formWidget.isValid(), "isValid");
583 }), 50);
584
585 return d;
586 },
587
588 function tearDown(){
589 handle.unwatch();
590 }
591 ]);
592
593 doh.register("validate()", function validate(){
594 formWidget.set("value", original);
595
596 // make the second and third DateTextBoxes invalid
597 dojo.byId("dtb2").value = "12/a";
598 dijit.byId("dtb2").validate(true);
599 dojo.byId("dtb3").value = "12/a";
600 dijit.byId("dtb3").validate(true);
601
602 // Since the required but empty ValidationTextBox has never been focused,
603 // it's not yet marked in an error state
604 doh.f(dojo.hasClass(dojo.byId("widget_rw"), "dijitValidationTextBoxError"), "required but empty not yet marked as error");
605
606 // validate() should focus the first DateTextBox and highlight
607 // the two invalid DateTextBoxes and the required but empty ValidationTextBox.
608 formWidget.validate();
609
610 doh.t(dojo.hasClass(dojo.byId("widget_rw"), "dijitValidationTextBoxError"), "required but empty marked as error");
611
612 // Check that focus went to invalid field. But on IE9+ focus change is asynchronous so use a timer.
613 var d = new doh.Deferred();
614 setTimeout(d.getTestCallback(function(){
615 doh.is("dtb2", dijit.focus.curNode.id, "focused on first invalid DateTextBox");
616 }), 0);
617 return d;
618 });
619
620 if(dojo.isFF >= 4 || dojo.isIE >= 10 || dojo.isWebKit){
621 // only works for HTML5 compliant browsers where novalidate is understood
622 // (also, hasAttribute() is not available on IE6/7)
623 doh.register("novalidate", function noValidate(){
624 // Making sure the parser picks up the flag and _WidgetBase copies it to this.domNode
625 doh.t(dijit.byId("noValidateForm").domNode.hasAttribute("novalidate"), "novalidate");
626 });
627 }
628
629 doh.run();
630 });
631
632 </script>
633 </head>
634 <body class="claro" role="main">
635 <h1>Form Widget Unit Test</h1>
636 <p>
637 The form widget takes data in a form and serializes/deserializes it, so
638 it can be submitted as a JSON string of nested objects.
639 </p>
640 <div style="color:red">Currently only widgets are supported, not raw elements.</div>
641 <!-- to test form submission, you'll need to create an action handler similar to
642 http://www.utexas.edu/teamweb/cgi-bin/generic.cgi
643 http://www.tipjar.com/cgi-bin/test -->
644 <form id="myForm" data-dojo-type="dijit/form/Form" data-dojo-props='encType:"multipart/form-data", action:"../formAction.html", method:"", target:"formSubmitIframe"'>
645 <script type="dojo/method" data-dojo-event="onReset">
646 return ("_onResetReturn" in this)? this._onResetReturn : confirm('Press OK to reset widget values');
647 </script>
648 <script type="dojo/method" data-dojo-event="onSubmit">
649 console.debug('Attempting to submit form w/values:\n',
650 dojo.toJson(this.get('value'),true)
651 );
652 if(this.validate()){
653 return confirm('Form is valid, press OK to submit');
654 }else{
655 alert('Form contains invalid data. Please correct first');
656 return false;
657 }
658 return true;
659 </script>
660 <p>Just HTML text</p>
661 <table style="border: 1px solid #9f9f9f;">
662 <thead>
663 <tr>
664 <th>Description</th>
665 <th>Name</th>
666 <th>Form node/widget</th>
667 </tr>
668 </thead>
669 <tbody>
670 <!--
671 <tr><td>text</td><td>testF</td><td><input type="text" name="testF" value="bar1" /></td></tr>
672 <tr><td>password</td><td>passwordF</td><td><input type="password" name="passwordF" value="bar4" /></td></tr>
673 <tr><td>hidden</td><td>hiddenF</td><td><input type="hidden" name="hiddenF" value="bar4" /></td></tr>
674 <tr><td>select</td><td>plop.noncombo</td><td>
675 <div class="group">
676 <select name="plop.noncombo">
677 <option value="1">one</option>
678 <option value="2">two</option>
679 <option value="3">three</option>
680 </select>
681 </div>
682
683 </td></tr>
684 -->
685
686 <tr>
687 <td>DateTextBox inside contentpane</td>
688 <td><label for="dtb1">foo.bar.baz.quux</label></td>
689 <td>
690 <div data-dojo-type="dijit/layout/ContentPane">
691 <input data-dojo-type="dijit/form/DateTextBox" data-dojo-props='id:"dtb1", name:"foo.bar.baz.quux", value:"2007-12-30" '/>
692 </div>
693 </td>
694 </tr>
695 <tr>
696 <td>DateTextBox 2</td>
697 <td><label for="dtb2">available.from</label></td>
698 <td>
699 <input data-dojo-type="dijit/form/DateTextBox" data-dojo-props='id:"dtb2", name:"available.from", value:"2005-01-02" '/>
700 </td>
701 </tr>
702 <tr>
703 <td>DateTextBox 3</td>
704 <td><label for="dtb3">available.to</label></td>
705 <td>
706 <input data-dojo-type="dijit/form/DateTextBox" data-dojo-props='id:"dtb3", name:"available.to", value:"2006-01-02" '/>
707 </td>
708 </tr>
709 <tr>
710 <td>ComboBox</td>
711 <td><label for="plopcombo">plop.combo</label></td>
712 <td>
713 <select data-dojo-type="dijit/form/ComboBox" id="plopcombo" data-dojo-props='name:"plop.combo" '>
714 <option value="one">one</option>
715 <option value="two">two</option>
716 <option value="three">three</option>
717 </select>
718 </td>
719 </tr>
720
721 <!--
722 <tr>
723 <td>textarea</td>
724 <td>myTextArea</td>
725 <td>
726 <textarea name="myTextArea">
727 text text text """ \\\/
728 </textarea>
729 </td>
730 </tr>
731 -->
732
733 <!--
734 <tr>
735 <td>CheckBox</td>
736 <td>cb1</td>
737 <td>
738 <input type="checkbox" name="cb1" value="1" /> 1
739 <input type="checkbox" name="cb1" value="2" checked="checked" /> 2
740 <input type="checkbox" name="cb1" value="3" checked="checked" /> 3
741 <input type="checkbox" name="cb1" value="4" /> 4
742 </td>
743 </tr>
744 -->
745
746 <tr>
747 <td>CheckBox widget</td>
748 <td>cb</td>
749 <td>
750 <input data-dojo-type="dijit/form/CheckBox" id="cb_1" name="cb" value="1"/> <label for="cb_1">1</label>
751 <input data-dojo-type="dijit/form/CheckBox" id="cb_2" name="cb" value="2" checked/> <label for="cb_2">2</label>
752 <input data-dojo-type="dijit/form/CheckBox" id="cb_3" name="cb" value="3" checked/> <label for="cb_3">3</label>
753 <input data-dojo-type="dijit/form/CheckBox" id="cb_4" name="cb" value="4"/> <label for="cb_4">4</label>
754 </td>
755 </tr>
756
757 <!--
758 <tr>
759 <td>radio</td>
760 <td>r1</td>
761 <td>
762 <input type="radio" name="r1" value="1" /> 1
763 <input type="radio" name="r1" value="2" /> 2
764 <input type="radio" name="r1" value="3" /> 3
765 <input type="radio" name="r1" value="4" /> 4
766 </td>
767 </tr>
768 -->
769
770 <tr>
771 <td>Radio widget</td><td>r</td>
772 <td id="radio-cells">
773 <input data-dojo-type="dijit/form/RadioButton" id="r_1" name="r" value="1"/> <label for="r_1">1</label>
774 <input data-dojo-type="dijit/form/RadioButton" id="r_2" name="r" value="2" checked/> <label for="r_2">2</label>
775 <input data-dojo-type="dijit/form/RadioButton" id="r_3" name="r" value="3"/> <label for="r_3">3</label>
776 <input data-dojo-type="dijit/form/RadioButton" id="r_4" name="r" value="4"/> <label for="r_4">4</label>
777 <input type="button" onclick="dojo.query('INPUT[type=radio]','radio-cells').forEach(function(n){dijit.getEnclosingWidget(n).set('checked',false);});return true;" value="Unset all radio buttons"/>
778 </td>
779 </tr>
780
781 <tr>
782 <td>Multi-select</td><td>ms1</td>
783 <td>
784 <select id="ms1" multiple data-dojo-type="dijit/form/MultiSelect"
785 data-dojo-props='name:"ms1", "aria-label":"ms1",
786 style:{height:"100px", width:"175px", border:"5px solid #ededed"}'>
787
788 <option value="TN">Tennessee</option>
789 <option value="VA" selected>Virginia</option>
790 <option value="WA" selected>Washington</option>
791 <option value="FL">Florida</option>
792 <option value="CA">California</option>
793
794 </select>
795 </td>
796 </tr>
797
798 <tr>
799 <td>Select</td><td>s1</td>
800 <td>
801 <select id="s1" data-dojo-type="dijit/form/Select"
802 data-dojo-props='name:"s1", style:{width:"175px"}, "aria-label":"s1"'>
803 <option value="TN">Tennessee</option>
804 <option value="VA" selected="selected">Virginia</option>
805 <option value="WA">Washington</option>
806 <option value="FL">Florida</option>
807 <option value="CA">California</option>
808
809 </select>
810 </td>
811 </tr>
812
813 <tr>
814 <td>Hidden input</td>
815 <td>h1</td>
816 <td>
817 <input id="h1" data-dojo-type="dijit/form/TextBox" data-dojo-props='name:"h1", type:"hidden", value:"hidden", "aria-label":"h1" '/>
818 </td>
819 </tr>
820
821 <tr>
822 <td>Auto-sizing textarea</td>
823 <td>t1</td>
824 <td>
825 <textarea id="t1" data-dojo-type="dijit/form/Textarea" data-dojo-props='name:"t1", "aria-label":"t1" '>line 1
826 line 2</textarea>
827 </td>
828 </tr>
829
830 <tr>
831 <td>Fixed size textarea</td>
832 <td>st1</td>
833 <td>
834 <textarea id="st1" data-dojo-type="dijit/form/SimpleTextarea" data-dojo-props='name:"st1", rows:"5", cols:"50", "aria-label":"st1" '>
835 simple line 1
836 simple line 2</textarea>
837 </td>
838 </tr>
839
840 <tr>
841 <td>Editor widget</td>
842 <td>richtext</td>
843 <td>
844 <textarea id="editor" name="richtext" data-dojo-type="dijit/Editor" data-dojo-props='"aria-label":"editor", plugins:["bold", "italic"]'><h1>original</h1><p>This is the default content</p></textarea>
845 </td>
846 </tr>
847
848 <tr>
849 <td>File upload</td>
850 <td>filename</td>
851 <td>
852 <input data-dojo-type="dijit/form/TextBox" data-dojo-props='name:"filename", type:"file", "aria-label":"filename" '/>
853 </td>
854 </tr>
855 <tr>
856 <td>Required Widget</td>
857 <td>requiredWidget</td>
858 <td>
859 <input data-dojo-type="dijit/form/ValidationTextBox" data-dojo-props='id: "rw", name:"requiredWidget", required:true, value:"", "aria-label":"rw" '/>
860 </td>
861 </tr>
862 <tr>
863 <td>Disabled Widget</td>
864 <td>disabledWidget</td>
865 <td>
866 <input data-dojo-type="dijit/form/TextBox" data-dojo-props='name:"disabledWidget", disabled:true, value:"Should not be returned", "aria-label":"disabled" '/>
867 </td>
868 </tr>
869 <tr>
870 <td>Disabled Required Widget</td>
871 <td>disabledRequiredWidget</td>
872 <td>
873 <input data-dojo-type="dijit/form/ValidationTextBox" data-dojo-props='id: "drw", name:"disabledRequiredWidget", disabled:true, required:true, value:"", "aria-label":"disabledRequired" '/>
874 </td>
875 </tr>
876 <tr>
877 <td>Read-only Widget</td>
878 <td>readOnlyWidget</td>
879 <td>
880 <input data-dojo-type="dijit/form/TextBox" data-dojo-props='name:"readOnlyWidget", readOnly:true, value:"Should be returned", "aria-label":"readonly" '/>
881 </td>
882 </tr>
883 <tr>
884 <td>Duplicate named TextBox 1</td>
885 <td>duplicate</td>
886 <td>
887 <input data-dojo-type="dijit/form/TextBox" data-dojo-props='name:"duplicate", value:"first", "aria-label":"duplicate" '/>
888 </td>
889 </tr>
890 <tr>
891 <td>Duplicate named TextBox 2</td>
892 <td>duplicate</td>
893 <td>
894 <input data-dojo-type="dijit/form/TextBox" data-dojo-props='name:"duplicate", value:"second", "aria-label":"duplicate2" '/>
895 </td>
896 </tr>
897 <tr>
898 <td>Duplicate named TextBox 3</td>
899 <td>duplicate</td>
900 <td>
901 <input data-dojo-type="dijit/form/TextBox" data-dojo-props='name:"duplicate", value:"third", "aria-label":"duplicate3" '/>
902 </td>
903 </tr>
904 </tbody>
905 </table>
906
907 <button data-dojo-type="dijit/form/Button" data-dojo-props='onClick:function(){ getValues(); }'>Get Values from form!</button>
908 <button data-dojo-type="dijit/form/Button" data-dojo-props='onClick:function(){ setValues(); }'>Set Values to form!</button>
909 <button data-dojo-type="dijit/form/Button" data-dojo-props='onClick:function(){ validate(); }'>Validate form!</button>
910 <button data-dojo-type="dijit/form/Button" data-dojo-props='type:"submit", value:"Submit"'>Submit</button>
911 <button data-dojo-type="dijit/form/Button" data-dojo-props='type:"reset"'>HTML Reset</button>
912 <button data-dojo-type="dijit/form/Button" data-dojo-props='type:"button", onClick:function(){ dijit.byId("myForm").reset() }'>reset()</button>
913 </form>
914 <button data-dojo-type="dijit/form/Button" data-dojo-props='type:"button",
915 onClick:function(){ dijit.byId("myForm").submit() }'>Submit programmatically</button>
916
917 <iframe name="formSubmitIframe" src="about:blank" onload="if(this.values)submittedValues(this.values)" style="display:none;"></iframe>
918
919 <form id="noValidateForm" data-dojo-type="dijit/form/Form" novalidate></form>
920 </body>
921 </html>