Changeset 2464
- Timestamp:
- 05/27/2008 10:47:17 AM (5 months ago)
- Location:
- trunk
- Files:
-
- 2 modified
-
HISTORY (modified) (1 diff)
-
framework/Web/Javascripts/source/prado/validator/validation3.js (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/HISTORY
r2463 r2464 6 6 BUG: Ticket#843 - TDataList alternatinItem issue after changes in rev 2227 (Christophe) 7 7 BUG: Ticket#849 - TDatePicker selecting current date problem (Christophe) 8 ENH: Added Prado.Validation.validateControl(id) on client side to validate a specific control (Michael) 8 9 9 10 Version 3.1.2 April 21, 2008 -
trunk/framework/Web/Javascripts/source/prado/validator/validation3.js
r2458 r2464 72 72 * <tt>groupID</tt> if present will only validate the validators 73 73 * in a particular group.</p> 74 * <p>Use <code>{@link Prado.Validation.validateControl}(controlClientID)</code> 75 * to trigger validation for a single control.</p> 74 76 * 75 77 * @object {static} Prado.Validation … … 106 108 } 107 109 }, 110 111 /** 112 * Validate all validators of a specific control. 113 * @function {boolean} ? 114 * @param {string} id - ID of DOM element to validate 115 * @return true if all validators are valid or no validators present, false otherwise. 116 */ 117 validateControl : function(id) 118 { 119 var formId=this.getForm(); 120 121 if (this.managers[formId]) 122 { 123 return this.managers[formId].validateControl(id); 124 } else { 125 throw new Error("A validation manager needs to be created first."); 126 } 127 }, 108 128 109 129 /** … … 209 229 Prado.ValidationManager.prototype = 210 230 { 231 /** 232 * Hash of registered validators by control's clientID 233 * @var controls 234 */ 235 controls: {}, 236 211 237 /** 212 238 * Initialize ValidationManager. … … 285 311 286 312 /** 313 * Perform validation for all validators of a single control. 314 * @function {boolean} ? 315 * @param {string} id - ID of DOM element to validate 316 * @return true if all validators are valid or no validators present, false otherwise. 317 */ 318 validateControl : function (id) 319 { 320 return this.controls[id] ? this.controls[id].invoke('validate',null).all() : true; 321 }, 322 323 /** 287 324 * Focus on the first validator that is invalid and options.FocusOnError is true. 288 325 * @function ? … … 372 409 addValidator : function(validator) 373 410 { 374 // Erase any existing validator with same options 375 this.validators = this.validators.reject(function(v) 376 { 377 return (v.options.ID==validator.options.ID); 378 }); 411 // Remove previously registered validator with same ID 412 // to prevent stale validators created by AJAX updates 413 this.removeValidator(validator); 414 379 415 this.validators.push(validator); 380 416 if(validator.group && !this.groups.include(validator.group)) 381 417 this.groups.push(validator.group); 418 419 if (typeof this.controls[validator.control.id] === 'undefined') 420 this.controls[validator.control.id] = Array(); 421 this.controls[validator.control.id].push(validator); 382 422 }, 383 423 … … 391 431 this.summaries.push(summary); 392 432 }, 433 434 /** 435 * Remove a validator from this manager 436 * @function ? 437 * @param {TBaseValidator} validator - Validator object 438 */ 439 removeValidator : function(validator) 440 { 441 this.validators = this.validators.reject(function(v) 442 { 443 return (v.options.ID==validator.options.ID); 444 }); 445 if (this.controls[validator.control.id]) 446 this.controls[validator.control.id].reject( function(v) 447 { 448 return (v.options.ID==validator.options.ID) 449 }); 450 }, 393 451 394 452 /** … … 474 532 { 475 533 /** 476 * Validat ionManager options534 * Validator options 477 535 * @var {object} options 478 536 */ … … 706 764 * @constructor {protected} ? 707 765 * @param {object} options - Options for initialization. 708 * @... {string} ID - ID of validat ion summary element.766 * @... {string} ID - ID of validator 709 767 * @... {string} FormID - ID of form of this manager. 710 768 * @... {string} ControlToValidate - ID of control to validate.
