2016-01-11 53 views
0

我在堆棧溢出上使用了一個示例here來創建自定義驗證文本區域小部件。我遇到的問題是小部件不會接受返回有效字符。有什麼我可以做的,以允許退貨?無論何時在窗口小部件中輸入回車,控件都會顯示紅色的無效指示符和'輸入的值無效'的消息。我使用的代碼如下:返回字符對於SimpleText區域和驗證文本框的混入無效

自定義部件:

define(["dojo/_base/declare", "dojo/_base/lang", "dijit/form/SimpleTextarea", "dijit/form/ValidationTextBox"], 
function (declare, lang, SimpleTextarea, ValidationTextBox) { 

     return declare('dijit.form.ValidationTextArea', [SimpleTextarea, ValidationTextBox], { 
      constructor: function (params) { 
       this.constraints = {}; 
       this.baseClass += ' dijitValidationTextArea'; 
      }, 
      templateString: "<textarea ${!nameAttrSetting} data-dojo-attach-point='focusNode,containerNode,textbox' autocomplete='off' placeHolder='${placeHolder}'></textarea>" 
     }) 
    }) 

標記:

<textarea data-dojo-type="Scripts/ValidationTextArea" 
            data-dojo-attach-point="taGoalsObjectives" style="width:425px; height:75px" 
            required='true' 
            placeHolder="max 2000 characters" 
            data-dojo-props="trim:true,maxLength:'2000'"></textarea> 

回答

0

找到答案在這裏StackOverflow上這個topic。增加了techscreen下面部件中模板字符串提供的部分解決方案:

pattern: "[\\S\\s]+", /* Match not-whitepsace or whitespace. Default pattern for ValidationTextBox is .* which does not match new line characters */