I\'m attempting to use dojo for the first time, so this may be be obvious.
I have a very simple form with one textarea in it that needs to be filled in.
My approach is slightly different to the previous two answers but it is hopefully more concise as it does not involve writing any validation code.
The out of the box dijit/form/SimpleTextarea extends a TextBox by replacing the control with a
My solution just defines a new text area Dijit by extending a ValidationTextBox.
That is, take the source from SimpleTextarea (90 lines and most of it comments) and replace TextBox with ValidationTextBox. Also override the default regex pattern (.*) to allow new line characters.
define("custom/ValidationTextarea", [
"dojo/_base/declare", // declare
"dojo/dom-class", // domClass.add
"dojo/sniff", // has("ie") has("opera")
"dijit/form/ValidationTextBox"
], function(declare, domClass, has, ValidationTextBox){
return declare("custom/ValidationTextarea", ValidationTextBox, {
baseClass: "dijitValidationTextBox dijitTextBox dijitTextArea",
...
pattern: "[\\S\\s]+", /* Match not-whitepsace or whitespace. Default pattern for ValidationTextBox is .* which does not match new line characters */
... remaining lines