| | 36 | validate: function(){ |
| | 37 | // summary: returns if the form is valid - same as isValid - but |
| | 38 | // provides a few additional (ui-specific) features. |
| | 39 | // 1 - it will highlight any sub-widgets that are not |
| | 40 | // valid |
| | 41 | // 2 - it will call focus() on the first invalid |
| | 42 | // sub-widget |
| | 43 | var didFocus = false; |
| | 44 | return dojo.every(dojo.map(this.getDescendants(), function(widget){ |
| | 45 | // Need to set this so that "required" widgets get their |
| | 46 | // state set. |
| | 47 | widget._hasBeenBlurred = true; |
| | 48 | var valid = !widget.validate || widget.validate(); |
| | 49 | if (!valid && !didFocus) { |
| | 50 | // Set focus of the first non-valid widget |
| | 51 | widget.focus(); |
| | 52 | didFocus = true; |
| | 53 | } |
| | 54 | return valid; |
| | 55 | }), "return item;"); |
| | 56 | }, |
| | 57 | |