More cleanup of input field after user error
parent
7502dc0689
commit
966eb3d073
|
@ -97,7 +97,6 @@ profileValidation.controller('profileValidationController', ['$scope', '$http',
|
|||
profileValidation.controller('pairedWithController', ['$scope',
|
||||
function($scope) {
|
||||
$scope.existingUser = null;
|
||||
|
||||
}
|
||||
]);
|
||||
|
||||
|
@ -152,15 +151,16 @@ profileValidation.directive('existingUsername', function($http) {
|
|||
require: 'ngModel',
|
||||
link: function (scope, element, attrs, ngModel) {
|
||||
element.bind("keyup", function (event) {
|
||||
ngModel.$setValidity('exists', false);
|
||||
if (element.val().length > 0) {
|
||||
ngModel.$setValidity('exists', false);
|
||||
} else {
|
||||
ngModel.$setPristine();
|
||||
}
|
||||
if (element.val()) {
|
||||
$http.get("/api/checkExistingUsername/" + element.val() + ' ').success(function (data) {
|
||||
console.log('in existing username function');
|
||||
if (element.val() == scope.existingUsername) {
|
||||
console.log("doesn't match a username");
|
||||
ngModel.$setValidity('exists', false);
|
||||
} else if (data) {
|
||||
console.log("matches a username")
|
||||
ngModel.$setValidity('exists', true);
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue