Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8609745
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T03:57:13+00:00 2026-06-12T03:57:13+00:00

I am trying to create a custom ValidationTextBox widget for an email address. We

  • 0

I am trying to create a custom ValidationTextBox widget for an email address. We have many areas in our system where we use an email address input and I want to create one widget that has the default regex, invalid messages, etc. The problem is there are two attributes: placeholder and maxlength that do not seem to be getting added to my extended class. My code is as follows:

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

    return lang.mixin(ValidationTextBox, {
    invalidMessage: "Please enter a valid email address.",
    missingMessage: "Please enter a valid email address.",
    regExp : "[a-zA-Z0-9._%-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$",
    maxlength : 50,
    placeholder : 'Your Email'
    });
});

If I use this on my page, the invalid messages work fine, but anywhere I use this, I do not see a placeholder, nor is a maxlength applied. In addition to the lang.mixin approach, I’ve also tried using the declare approach spelled out here: http://www.sitepen.com/blog/2010/07/01/creating-and-enhancing-dojo-classes/. I get the same result.

Any idea what I’m missing?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T03:57:14+00:00Added an answer on June 12, 2026 at 3:57 am

    See both options you described in action at http://jsfiddle.net/phusick/eLkwb/

    Use dojo/_base/lang::extend instead of mixin:

    lang.extend(ValidationTextBox, {
        invalidMessage: "Please enter a valid email address.",
        missingMessage: "Please enter a valid email address.",
        pattern: "[a-zA-Z0-9._%-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$",
        required: true,
        maxLength: 3,
        placeHolder : 'Your Email'
    });
    

    Also please note:

    • regExp is deprecated, use pattern instead
    • attributes are case sensitive: so placeHolder, maxLength
    • make sure to dojo/parser::parse() after the extension took place (for markup instantiation)
    • maxLength does not work for some reason (see declare workaround below)

    Accomplishing the same via subclassing:

    define([
        "dojo/_base/declare",
        "dijit/form/ValidationTextBox"
    ], function(
        declare,          
        ValidationTextBox
    ) {
    
        return declare([ValidationTextBox], {
            postCreate: function() {
                // a workaround to make maxLength working
                this.inherited(arguments);            
                this.set("maxLength", this.maxLength);
            },            
            invalidMessage: "Please enter a valid email address.",
            missingMessage: "Please enter a valid email address.",
            pattern: "[a-zA-Z0-9._%-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$",
            required: true,
            maxLength: 3,
            placeHolder : 'Your Email'
        });
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to create a custom Dojo ValidationIdBox widget that inherits from ValidationTextBox.
I'm trying to create a custom form input that utilizes some images, it should
I'm trying to create a custom component to extend PrimeFaces. I have a simple
I'm trying to create a custom ArrayAdapter to use for my ListFragment . Right
I am trying to create custom AlertDialog with two EditText fields for input. Here
Im trying to create a custom formatter in Symfony 1.4. I have embedded form
I am trying to create a custom user control in WPF. I want to
I'm trying to create a custom membership system in ASP.NET MVC3 . I know
I'm trying to create a custom MembershipUser and I have to overide the GetUser()
I'm trying to create a custom DQL function to allow me to use the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.