2011-03-01 74 views
2

我是Dojo編程的新手,嘗試爲用戶名輸入創建ValidationTextBox。我想有三個標準:1,用戶只能輸入字母數字字符和2用戶名的最小長度爲6個字符3.需要該領域Dojo中的自定義ValidationTextBox

到目前爲止,我輸入的樣子:

<input name="username" 
    type="text" 
    id="username" 
    class="reqd1" 
    required="true" 
    trim="true" 
    lowercase="true" 
    promptMessage="Username" 
    invalidMessage="Please only enter alphanumeric characters." 
    maxlength="12" 
    regExp="[\w]+" 
    intermediateChanges="false" 
    dojoType="dijit.form.ValidationTextBox" /> 

我有三個問題: 1.我如何檢查用戶名字段的最小字符? 2.有沒有辦法以編程方式更改invalidMessage? 3.如何在不使用regEx的情況下檢查用戶名字段的長度?

回答

4
  1. 的regexp = 「\ W {6,12}」
  2. dijit.byId( 「用戶名」)集( 「invalidMessage」, 「新信息」);
  3. 我認爲regExp是您的案例中的最佳方式