Add: account_validator

This commit is contained in:
2018-07-18 20:50:14 +09:00
parent 4edd637b05
commit 53565189a2
6 changed files with 189 additions and 44 deletions
+38 -14
View File
@@ -38,15 +38,22 @@ let selectedAccountTypeText = "";
let tab1, tab2, tab3;
let accountValidator = new AccountValidator();
$(document).ready(function() {
tab1 = $("#page-tabs li").filter(":eq(0)");
tab2 = $("#page-tabs li").filter(":eq(1)");
tab3 = $("#page-tabs li").filter(":eq(2)");
});
function check_id() {
function checkMaestroID() {
maestro_name = $("#maestro_name").val();
if(!accountValidator.isValidMaestroID(maestro_name)) {
onErrorMaestroID(accountValidator.messageForInvalidMaestroID(maestro_name));
return;
}
sendRequestServer( //url, sendParams, onSuccess, onFail, isDebugMode);
"./../server/maestro/check_id.php",
"maestro_name=" + maestro_name,
@@ -58,20 +65,31 @@ function check_id() {
(errorMessage, errorCode) => {
isAvailableID = false;
if($("#error_message").length) {
$("#error_message").text(errorMessage);
}
$("#maestro_name").val("");
$("#maestro_name").focus();
onErrorMaestroID(errorMessage);
}
);
}
function onErrorMaestroID(message) {
if($("#error_message").length) {
$("#error_message").text(message);
}
function check_data() {
$("#maestro_name").val("");
$("#maestro_name").focus();
}
function onErrorMaestroPW(message) {
if($("#error_message").length) {
$("#error_message").text(message);
}
$("#password").val("");
$("#password").focus();
}
function checkData() {
if(!isAvailableID) {
$("#error_message").text("아이디 중복 확인을 해 주세요.");
$("#check_id").focus();
@@ -79,11 +97,15 @@ function check_data() {
}
password = $("#password").val();
if(password.length === 0) {
$("#error_message").text("패스워드를 입력해 주세요.");
$("#password").focus();
if(!accountValidator.isValidMaestroPW(password)) {
onErrorMaestroPW(accountValidator.messageForInvalidMaestroPW(password));
return;
}
// if(password.length === 0) {
// $("#error_message").text("패스워드를 입력해 주세요.");
// $("#password").focus();
// return;
// }
email = $("#email").val();
if(email.length === 0) {
@@ -110,6 +132,8 @@ function check_data() {
$(".account_type").append(selectedAccountTypeText);
$(".price_account").append(selectedAccountTypeText);
$("#error_message").text("");
$("#input_data").css("display", "none");
$("#register_account").css("display", "block");
@@ -170,7 +194,7 @@ function register_account() {
<div id="input_data">
(필수) 마에스트로 아이디 : <input type="text" id="maestro_name" value="test" >
<button id="check_id" onClick="check_id()">중복 확인</button><br/>
<button id="check_id" onClick="checkMaestroID()">중복 확인</button><br/>
(필수) 암호 : <input id="password" value="test" type="password" name="password"><br/>
(필수) 이메일 : <input id="email" value="test@test.com" name="email"><br/>
(필수) 학생 수 :
@@ -211,7 +235,7 @@ function register_account() {
</ul>
<div class="col alignCenter">
<a id="maestro_register" class="btn btn-sea width400" onClick="check_data()">등록 신청</a>
<a id="maestro_register" class="btn btn-sea width400" onClick="checkData()">등록 신청</a>
</div>
</div>