File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -325,3 +325,24 @@ scope.validationInvalidHandler = function(message){
325325 displayMessage (message, ' error' );
326326};
327327```
328+
329+
330+ ### ** Setup a global valid/invalid/reset callback in config phase**
331+
332+ ``` javascript
333+ // your module
334+ angular .module (' yourApp' , [' validation' ])
335+ .config ([' $validationProvider' , function ($validationProvider ) {
336+ validationProvider .validCallback = function (element ) {
337+ $ (element).parents (' .validator-container:first' ).removeClass (' has-error' ).addClass (' has-success-tick' );
338+ };
339+ validationProvider .invalidCallback = function (element ) {
340+ $ (element).parents (' .validator-container:first' ).removeClass (' has-success-tick' ).addClass (' has-error' );
341+ };
342+ validationProvider .resetCallback = function (element ) {
343+ $ (element).parents (' .validator-container:first' ).removeClass (' has-error' );
344+ };
345+ }]);
346+ ```
347+
348+
Original file line number Diff line number Diff line change 238238 */
239239 this . invalidCallback = null ;
240240
241+ /**
242+ * Do this function when reset is performed
243+ * @param element
244+ */
245+ this . resetCallback = null ;
246+
241247 /**
242248 * reset the specific form
243249 * @param form
286292 validate : this . validate ,
287293 validCallback : this . validCallback ,
288294 invalidCallback : this . invalidCallback ,
295+ resetCallback : this . resetCallback ,
289296 reset : this . reset
290297 } ;
291298 } ] ;
574581 ctrl . $render ( ) ;
575582 if ( attrs . messageId ) angular . element ( document . querySelector ( '#' + attrs . messageId ) ) . html ( '' ) ;
576583 else element . next ( ) . html ( '' ) ;
584+
585+ if ( $validationProvider . resetCallback ) $validationProvider . resetCallback ( element ) ;
577586 } ) ;
578587 } ) ;
579588
Original file line number Diff line number Diff line change 2626 " validator" ,
2727 " client-side"
2828 ],
29+ "main" : " ./dist/angular-validation.js" ,
2930 "bugs" : " https://github.com/huei90/angular-validation/issues" ,
3031 "devDependencies" : {
3132 "grunt" : " ~0.4.4" ,
Original file line number Diff line number Diff line change 232232 */
233233 this . invalidCallback = null ;
234234
235+ /**
236+ * Do this function when reset is performed
237+ * @param element
238+ */
239+ this . resetCallback = null ;
240+
235241 /**
236242 * reset the specific form
237243 * @param form
280286 validate : this . validate ,
281287 validCallback : this . validCallback ,
282288 invalidCallback : this . invalidCallback ,
289+ resetCallback : this . resetCallback ,
283290 reset : this . reset
284291 } ;
285292 } ] ;
Original file line number Diff line number Diff line change 225225 ctrl . $render ( ) ;
226226 if ( attrs . messageId ) angular . element ( document . querySelector ( '#' + attrs . messageId ) ) . html ( '' ) ;
227227 else element . next ( ) . html ( '' ) ;
228+
229+ if ( $validationProvider . resetCallback ) $validationProvider . resetCallback ( element ) ;
228230 } ) ;
229231 } ) ;
230232
You can’t perform that action at this time.
0 commit comments