Ticket #6005: FormValidation.patch

File FormValidation.patch, 1.6 kB (added by nathan, 11 months ago)

Patch which adds: 1 - dijit.form.Form.validate(), 2 - returns the boolean state from ValidationTextBox?.validate (and all subclasses), 3 - adds a testcase

  • dijit/form/ValidationTextBox.js

     
    105105                                } 
    106106                        } 
    107107                        this.displayMessage(message); 
     108                        return isValid; 
    108109                }, 
    109110 
    110111                // currently displayed message 
     
    169170 
    170171                validate: function(){ 
    171172                        this.valueNode.value = this.toString(); 
    172                         this.inherited(arguments); 
     173                        return this.inherited(arguments); 
    173174                }, 
    174175 
    175176                setAttribute: function(/*String*/ attr, /*anything*/ value){ 
  • dijit/form/Form.js

     
    3333                        }); 
    3434                }, 
    3535 
     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                 
    3658                setValues: function(/*object*/obj){ 
    3759                        // summary: fill in form values from a JSON structure 
    3860