2011-03-01 65 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是您的案例中的最佳方式