Question

In my example below I'm using a dijit.form.DateTextBox:

<input type="text" name="startDate" dojoType="dijit.form.DateTextBox" constraints="{datePattern:'MM/dd/yyyy'}"  value='<c:out value="${sessionScope.adminMessageForm.startDate}"/>' />

So for example, if the user starts to enter "asdf" into the date the field turns yellow and a popup error message appears saying The value entered is not valid.. Even if I remove the constraints="{datePattern:'MM/dd/yyyy'}" it still validates.

Without going into details as to why, I would like to be able keep the dojoType and still prevent validation in particular circumstances.

Was it helpful?

Solution

Try overriding the validate method in your markup.

This will work (just tested):

<input type="text" name="startDate" dojoType="dijit.form.DateTextBox" 
  constraints="{datePattern:'MM/dd/yyyy'}"  
  value='<c:out value="${sessionScope.adminMessageForm.startDate}"/>'
  validate='return true;'
/>

OTHER TIPS

My only suggestion is to programmatically remove the dojoType on the server-side or client-side. It is not possible to keep the dojoType and not have it validate. Unless you create your own type that has you logic in it.

I had a similar problem, where the ValidationTextBox met all my needs but it was necessary to disable the validation routines until after the user had first pressed Submit.

My solution was to clone this into a ValidationConditionalTextBox with a couple new methods:

    enableValidator:function() {
        this.validatorOn = true;
    },

    disableValidator: function() {
        this.validatorOn = false;
    },

Then -- in the validator:function() I added a single check:

        if (this.validatorOn)
        { ... }

Fairly straightforward, my default value for validatorOn is false (this appears right at the top of the javascript). When my form submits, simply call enableValidator(). You can view the full JavaScript here:

http://lilawnsprinklers.com/js/dijit/form/ValidationTextBox.js

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top