Ticket #8037: 8037_2.patch
File 8037_2.patch, 2.2 KB (added by , 14 years ago) |
---|
-
_source/plugins/dialog/plugin.js
103 103 : input.setAttribute( 'aria-invalid', true ); 104 104 } 105 105 106 if ( !isValid ) 107 { 108 if ( this.select ) 109 this.select(); 110 else 111 this.focus(); 112 } 113 114 msg && alert( msg ); 115 106 116 this.fire( 'validated', { valid : isValid, msg : msg } ); 107 117 } 108 118 … … 294 304 if ( item.validate ) 295 305 { 296 306 var retval = item.validate( this ), 297 i sValid = retval === true;307 invalid = typeof ( retval ) == 'string' || retval === false; 298 308 299 if ( !isValid )309 if ( invalid ) 300 310 { 301 if ( item.select )302 item.select();303 else304 item.focus();305 306 311 evt.data.hide = false; 307 312 evt.stop(); 308 313 } 309 310 handleFieldValidated.call( item, isValid, typeof retval == 'string' ? retval : undefined );311 return !isValid;314 315 handleFieldValidated.call( item, !invalid, typeof retval == 'string' ? retval : undefined ); 316 return invalid; 312 317 } 313 318 }); 314 319 }, this, null, 0 ); … … 2984 2989 passed = passed || functions[i]( value ); 2985 2990 } 2986 2991 2987 if ( !passed ) 2988 { 2989 if ( msg !== undefined ) 2990 alert( msg ); 2991 if ( this.select || this.focus ) 2992 { 2993 if ( this.select ) 2994 this.select(); 2995 else 2996 this.focus(); 2997 } 2998 2999 return false; 3000 } 3001 3002 return true; 2992 return !passed ? msg : true; 3003 2993 }; 3004 2994 }, 3005 2995 … … 3012 3002 return function() 3013 3003 { 3014 3004 var value = this && this.getValue ? this.getValue() : arguments[0]; 3015 if ( !regex.test( value ) ) 3016 { 3017 if ( msg !== undefined ) 3018 alert( msg ); 3019 if ( this && ( this.select || this.focus ) ) 3020 { 3021 if ( this.select ) 3022 this.select(); 3023 else 3024 this.focus(); 3025 } 3026 return false; 3027 } 3028 return true; 3005 return !regex.test( value ) ? msg : true; 3029 3006 }; 3030 3007 }, 3031 3008