@@ -27,7 +27,6 @@ angular
2727 validationService . prototype . addValidator = addValidator ;
2828 validationService . prototype . checkFormValidity = checkFormValidity ;
2929 validationService . prototype . removeValidator = removeValidator ;
30- validationService . prototype . clearValidationSummary = clearValidationSummary ;
3130 validationService . prototype . setGlobalOptions = setGlobalOptions ;
3231
3332 return validationService ;
@@ -74,7 +73,7 @@ angular
7473 attrs = mergeObjects ( self . validationAttrs , attrs ) ;
7574
7675 // watch the element for any value change, validate it once that happen
77- attrs . scope . $watch ( attrs . elmName , function ( newVal , oldVal ) {
76+ attrs . scope . $watch ( attrs . elmName , function ( newVal , oldVal ) {
7877 if ( newVal === undefined && oldVal !== undefined ) {
7978 self . commonObj . updateErrorMsg ( "INVALID_KEY_CHAR" , { valid : false , translate : true } ) ;
8079 return ;
@@ -85,17 +84,11 @@ angular
8584
8685 self . commonObj . initialize ( attrs . scope , attrs . elm , attrs , attrs . ctrl ) ;
8786 attemptToValidate ( self , newVal ) ;
88- } , true ) ; // $watch()
87+ } , true ) ; // $watch()
8988
9089 return self ;
91- } // addValidator()
90+ } // addValidator()
9291
93- function clearValidationSummary ( obj ) {
94- if ( typeof obj === "undefined" || typeof obj . $validationSummary === "undefined" ) {
95- throw 'checkFormValidity() requires a valid Angular Form or $scope object passed as argument to function properly (ex.: $scope.form1 OR $scope).' ;
96- }
97- obj . $validationSummary = [ ] ;
98- }
9992 /** Is the Form all valid? Loop through Validation Summary to get the answer, if any errors are there then display them and return false
10093 * @param object Angular Form or Scope Object
10194 * @return bool isFormValid
@@ -110,12 +103,13 @@ angular
110103 // loop through $validationSummary and display errors when found on each field
111104 for ( var i = 0 , ln = obj . $validationSummary . length ; i < ln ; i ++ ) {
112105 isValid = false ;
113- elm = obj . $validationSummary [ i ] . obj . elm ;
114- ctrl = obj . $validationSummary [ i ] . obj . ctrl ;
106+ elmName = obj . $validationSummary [ i ] . field ;
107+ elm = angular . element ( document . querySelector ( '[name="' + elmName + '"]:not([disabled]):not([ng-disabled]' ) ) ;
108+ ctrl = angular . element ( elm ) . controller ( 'ngModel' ) ;
115109
116110 if ( ! ! elm && elm . length > 0 ) {
117111 ctrl . $setTouched ( ) ; // make the element as it was touched for CSS
118- self . commonObj . updateErrorMsg ( obj . $validationSummary [ i ] . message , { valid : false , obj : obj . $validationSummary [ i ] . obj , submitted : true } ) ;
112+ self . commonObj . updateErrorMsg ( obj . $validationSummary [ i ] . message , { valid : false , elm : elm , submitted : true } ) ;
119113 }
120114 }
121115 return isValid ;
0 commit comments