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

  • Home
  • SEARCH
  • 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 7856211
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T20:38:07+00:00 2026-06-02T20:38:07+00:00

I am trying to create a custom Dojo ValidationIdBox widget that inherits from ValidationTextBox.

  • 0

I am trying to create a custom Dojo ValidationIdBox widget that inherits from ValidationTextBox. My custom widget will add async duplicate ID checking with a back-end server.

I sub-classed dijit.form.ValidationTextBox and modified two methods: isValid() and validate(). However, I can’t get the validation to fully work. The widget catches and highlights problems like missing required input. It even catches when there is a duplicate ID (the tooltip appears), but it fails to highlight the field as expected.

I have tried to isolate my problem with a simplified code snippet below. It is mostly the origininal Dojo code with some minor modifications. My general strategy is to let the widget validate as a regular ValidationTextBox, then test for a duplicate ID. I modified isValid() to have two modes: plain validation and validation with uniqueness check. Currently, the uniqueness test intentionally always fails.

In a similar fashion, I modified validate() to do its normal thing, then do some additional processing if normal validation succeeds but the validation with uniqueness test fails. I tried to mirror the same logic as when the ValidationTextBox is in an error state, but the same effects are not mirrored: The ‘ID not available’ tooltip appears, but the red outline with exclamation mark does not appear.

I examined ValidationTextBox’s code, but I cannot figure out how that special styling is triggered… can someone explain how ValidationTextArea works? Specifically I’m not quite sure how this._maskValidSubsetError, aria-invalid, and this.state are used.

(Also sometimes, I want the tooltip to appear, but not the red styling. Like to show when AJAX duplicate ID check request is processing.)

// If ValidationTextBoxValidates
isValid: function(isFocused, requireUnique) {
    if (typeof requireUnique === 'undefined') requireUnique = false;

    var isValid = this.inherited(arguments);
    var isUnique = false;

    return (requireUnique ? (isValid && isUnique) : isValid);
},

validate: function(/*Boolean*/ isFocused){
    // summary:
    //        Called by oninit, onblur, and onkeypress.
    // description:
    //        Show missing or invalid messages if appropriate, and highlight textbox field.
    // tags:
    //        protected
    var message = "";
    var isValid = this.disabled || this.isValid(isFocused);
    if(isValid){ this._maskValidSubsetError = true; }
    var isEmpty = this._isEmpty(this.textbox.value);
    var isValidSubset = !isValid && isFocused && this._isValidSubset();
    this._set("state", isValid ? "" : (((((!this._hasBeenBlurred || isFocused) && isEmpty) || isValidSubset) && this._maskValidSubsetError) ? "Incomplete" : "Error"));
    this.focusNode.setAttribute("aria-invalid", isValid ? "false" : "true");

    if(this.state == "Error"){
        this._maskValidSubsetError = isFocused && isValidSubset; // we want the error to show up after a blur and refocus
        message = this.getErrorMessage(isFocused);
    }else if(this.state == "Incomplete"){
        message = this.getPromptMessage(isFocused); // show the prompt whenever the value is not yet complete
        this._maskValidSubsetError = !this._hasBeenBlurred || isFocused; // no Incomplete warnings while focused
    }else if(isEmpty){
        message = this.getPromptMessage(isFocused); // show the prompt whenever there's no error and no text
    }

    /// Begin custom widget code
    if (isValid && !this.isValid(isFocused, true) ) {
        isValid = false;

        var isValidSubset = !isValid && isFocused && this._isValidSubset();

        this._maskValidSubsetError = isFocused && isValidSubset; // we want the error to show up after a blur and refocus
        message = 'ID not available';

        this.focusNode.setAttribute("aria-invalid", isValid ? "false" : "true");
    }
    /// End custom widget code

    this.set("message", message);
    return isValid;
},
  • 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-02T20:38:08+00:00Added an answer on June 2, 2026 at 8:38 pm

    might be missing the obvious, hidden amongst a cloud of inline &&|| ;)))))

    The point in the blur/keypress mechanism is that the tooltip will only be visible on the box that is currently shown, hence _maskValid

    Have you tried this.set("state", this.isUnique() ? "" : "Error"); ??

    Widgets are Stateful and the .set might just do the trick, firing an event or publish a topic

    • 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 widget that prevents the transistion to
I was trying to create a custom combobox that inherited from ComboBox, but I've
I'm trying to create a custom Dojo widget for my application. <!-- Dojo widget
I am trying to create a custom Templated Widget in dojo. I need to
I'm trying to create custom view that draws image downloaded from Url. The code
I'm trying to create a custom UIButton that should look like a UIButtonTypeRoundedRect. In
I am trying to create a custom property in a extended control, so that
I am trying to create a custom context processor which will render a list
I am trying to create a Custom control derived from a standard Grid. I
I'm trying to create a custom audio effect by extending from the class android.media.audiofx.AudioEffect

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.