Skip to content
This repository was archived by the owner on Jul 1, 2020. It is now read-only.

Commit feae09c

Browse files
committed
fixed issue with mistyped validationErrorTo
If validationError has been mistyped, the code will not find requested element. It will then just append a new element as is standard functionality. But it will never try to find the added element if it revalidates, and add a new message for each validation. This should fix that problem
1 parent b1446eb commit feae09c

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/validation-common.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,11 @@ angular
210210
var firstChar = self.validatorAttrs.validationErrorTo.charAt(0);
211211
var selector = (firstChar === '.' || firstChar === '#') ? self.validatorAttrs.validationErrorTo : '#'+self.validatorAttrs.validationErrorTo;
212212
errorElm = angular.element(document.querySelector(selector));
213-
}else {
213+
}
214+
// errorElm can be empty due to:
215+
// 1. validationErrorTo has not been set
216+
// 2. validationErrorTo has been mistyped, and if mistyped, use regular functionality
217+
if(!errorElm || errorElm.length === 0){
214218
// most common way, let's try to find our <span class="validation-inputName">
215219
errorElm = angular.element(document.querySelector('.validation-'+elmInputName));
216220
}

0 commit comments

Comments
 (0)