Add: check player name, enterCode before add player

This commit is contained in:
2018-07-19 16:39:07 +09:00
parent c8b1e15447
commit 54b8bdb3a2
8 changed files with 163 additions and 51 deletions
@@ -1,5 +1,7 @@
<script type="text/javascript">
let accountValidator = new AccountValidator();
$(document).ready(function() {
addPlayerListManager = new PlayerListManager(
$("#add_player_list"),
@@ -13,6 +15,17 @@ function addPlayer() {
let playerName = $("#add_player_name").val();
let enterCode = $("#add_player_enter_code").val();
if(!accountValidator.isValidPlayerID(playerName)) {
console.log("Error - playerName : " + playerName);
onErrorPlayerID(accountValidator.messageForInvalidPlayerID(playerName));
return;
} else if(!accountValidator.isValidPlayerPW(enterCode)) {
console.log("Error - enterCode : " + enterCode);
onErrorPlayerPW(accountValidator.messageForInvalidPlayerPW(enterCode));
return;
}
/*
if(playerName.length === 0) {
// $("#add_player_notice").val("학생 이름을 입력하세요.");
$("#error_message").text("학생 이름을 입력하세요.");
@@ -24,6 +37,7 @@ function addPlayer() {
$("#add_player_enter_code").focus();
return;
}
*/
sendRequestServer( //url, sendParams, onSuccess, onFail, isDebugMode);
"./../server/player/add_player.php",
@@ -42,6 +56,25 @@ function addPlayer() {
);
}
function onErrorPlayerID(message) {
if($("#error_message").length) {
$("#error_message").text(message);
}
$("#maestro_name").val("");
$("#maestro_name").focus();
}
function onErrorPlayerPW(message) {
if($("#error_message").length) {
$("#error_message").text(message);
}
$("#password").val("");
$("#password").focus();
}
</script>