From 966eb3d073f48d410fc3f3e08f8433c16ba372f5 Mon Sep 17 00:00:00 2001 From: Nathan Leniz Date: Sat, 24 Jan 2015 19:16:28 -0500 Subject: [PATCH] More cleanup of input field after user error --- public/js/main.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/public/js/main.js b/public/js/main.js index b333e61ad6d..c04ee6e31c8 100644 --- a/public/js/main.js +++ b/public/js/main.js @@ -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); } });