Skip to content

Commit

Permalink
Validations on add collaborator
Browse files Browse the repository at this point in the history
Duplicate email id not allowed. Username, email and password are
mandatory fields.
  • Loading branch information
Anuja Kumar committed Aug 7, 2015
1 parent 0c8d664 commit 3ce3653
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion src/main/resources/static/js/views/main-menu-view.js
Original file line number Diff line number Diff line change
Expand Up @@ -597,6 +597,11 @@ $('#manageCollaboratorsModal .modal-body').on('click', '#addCollaborator', funct
});

$('#manageCollaboratorsModal .modal-body').on('click', '#saveCollaborator', function(){
if($("#addCollaboratorForm").valid()){
APP.users.fetch({
success : function(response){
var collaboratorWithSameEmail = response.findWhere({email : $("#collaboratorEmailId").val()});
if(!collaboratorWithSameEmail){
$.ajax({
url : APP.config.baseUrl + '/users',
type : 'post',
Expand Down Expand Up @@ -625,6 +630,25 @@ $('#manageCollaboratorsModal .modal-body').on('click', '#saveCollaborator', func
}
});
}
});
});
}
else{
$('#collaboratorEmailId').after('<label class="text-danger" id="collaborator-add-error">Email id already exists</label>');
}
} //success

});
}
});

$('#manageCollaboratorsModal .modal-body').on('keyup', '#collaboratorEmailId', function(){
if($('#collaboratorEmailId').val() == ''){
$('#collaborator-add-error').remove();
};
});

$("#manageCollaboratorsModal").on('show.bs.modal',function(e){
$("#collaborator-add-error").text("");
});

});

0 comments on commit 3ce3653

Please sign in to comment.