Ticket #6005: FormValidation.2.3.patch

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

Updated patch - fixes scrolling tooltip issue and moves test case into Form.html

  • dijit/tests/form/Form.html

     
    130130        http://www.tipjar.com/cgi-bin/test --> 
    131131<form dojoType="dijit.form.Form" id="myForm" encType="multipart/form-data" action="" method=""  
    132132        onreset="return confirm('Press OK to reset widget values')" 
    133         onsubmit="alert('Attempting to submit form w/values:\n'+dojo.toJson(this.getValues(),true));if(this.isValid()){return confirm('Form is valid, press OK to submit');}else{alert('Form contains invalid data.  Please correct first');return false;}" 
     133        onsubmit="alert('Attempting to submit form w/values:\n'+dojo.toJson(this.getValues(),true));if(this.validate()){return confirm('Form is valid, press OK to submit');}else{alert('Form contains invalid data.  Please correct first');return false;}" 
    134134> 
    135135<p>Just HTML text</p> 
    136136<table border=2> 
  • 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                                        dijit.scrollIntoView(widget.containerNode||widget.domNode); 
     52                                        widget.focus(); 
     53                                        didFocus = true; 
     54                                } 
     55                                return valid; 
     56                        }), "return item;"); 
     57                }, 
     58                 
    3659                setValues: function(/*object*/obj){ 
    3760                        // summary: fill in form values from a JSON structure 
    3861