Marco
Marco

Reputation: 23

Custom ValidationTextBox in Dojo

I am new to Dojo programming and trying to create a ValidationTextBox for username input. I would like to have three criteria: 1. users can only input alphanumeric characters and 2. minimum length of a username is 6 character 3. this field is required

So far my input looks like:

<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" />

I have three questions: 1. how I can check for the the minimum character of the username field? 2. Is there a way to change the invalidMessage programatically? 3. How I can check the length of the username field without using regEx?

Upvotes: 2

Views: 4245

Answers (1)

ivalkeen
ivalkeen

Reputation: 1411

  1. regExp="\w{6,12}"
  2. dijit.byId("username").set("invalidMessage", "new message");
  3. I think regExp is the best way in your case

Upvotes: 4

Related Questions