More cleanup of input field after user error

pull/51/head
Nathan Leniz 2015-01-24 19:16:28 -05:00
parent 7502dc0689
commit 966eb3d073
1 changed files with 5 additions and 5 deletions

View File

@ -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);
}
});