diff options
author | Andrew Dolgov <[email protected]> | 2020-02-28 13:53:45 +0300 |
---|---|---|
committer | Andrew Dolgov <[email protected]> | 2020-02-28 13:53:45 +0300 |
commit | f24ece85a6ea85ccff5fcdab2730d248892746fc (patch) | |
tree | b20a131f8168bc2fb95e1acd2f4d9d4c937701a9 /js/form/ValidationTextArea.js | |
parent | 2fefb4fd8741b38f28831f2da9e359ab4f7fa8a6 (diff) |
add validationtextarea control, use it for filter match editor
Diffstat (limited to 'js/form/ValidationTextArea.js')
-rw-r--r-- | js/form/ValidationTextArea.js | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/js/form/ValidationTextArea.js b/js/form/ValidationTextArea.js new file mode 100644 index 000000000..a7993f716 --- /dev/null +++ b/js/form/ValidationTextArea.js @@ -0,0 +1,33 @@ +// https://stackoverflow.com/questions/19317258/how-to-use-dijit-textarea-validation-dojo-1-9 + +define(["dojo/_base/declare", "dojo/_base/lang", "dijit/form/SimpleTextarea", "dijit/form/ValidationTextBox"], + function(declare, lang, SimpleTextarea, ValidationTextBox) { + + return declare('fox.form.ValidationTextArea', [SimpleTextarea, ValidationTextBox], { + constructor: function(params){ + this.constraints = {}; + this.baseClass += ' dijitValidationTextArea'; + }, + templateString: "<textarea ${!nameAttrSetting} data-dojo-attach-point='focusNode,containerNode,textbox' autocomplete='off'></textarea>", + validator: function(value, constraints) { + //console.log(this, value, constraints); + + if (this.required && this._isEmpty(value)) + return false; + + if (this.validregexp) { + try { + new RegExp("/" + value + "/"); + } catch (e) { + return false; + } + } + + return value.match(new RegExp(this._computeRegexp(constraints))); + + /*return (new RegExp("^(?:" + this._computeRegexp(constraints) + ")"+(this.required?"":"?")+"$",["m"])).test(value) && + (!this.required || !this._isEmpty(value)) && + (this._isEmpty(value) || this.parse(value, constraints) !== undefined); // Boolean*/ + } + }) + }); |