Skip to content Skip to sidebar Skip to footer

Validating / Clearing All Inputboxes Using Dojo

1)I have a dojo widget inside which i loads 2 more widgets.Now at some point i want to clear all text boxes within the widget.One method is : this.myAttachPoint.value=''. But doi

Solution 1:

Put all your textboxes inside a dijit.form.Form element. When you want to clear all of the textboxes then you can do

dojo.forEach(dijit.byId('myForm').getDescendants(), function(formWidget) {
    formWidget.attr('value', null);
    //or you could just clear the displayedValue, or...
});

where myForm is the id of your dijit.form.Form widget.

This will only work for textboxes so don't put any other type of form widgets inside the form.

This will clear all text boxes in the form. If you only want to clear some of the elements then you will have to introduce conditional logic into your forEach loop.


Post a Comment for "Validating / Clearing All Inputboxes Using Dojo"