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