Add: Email validator

This commit is contained in:
2018-12-22 18:18:09 +09:00
parent bebde27337
commit 618bc4453a
2 changed files with 27 additions and 2 deletions
+15
View File
@@ -6,6 +6,8 @@ function AccountValidator() {
this.patternPlayerPW = /^[0-9]{2,8}$/;
this.patternLicenseTimerPW = /^[0-9]{2,8}$/;
this.patternEmailAddress = /([a-zA-Z0-9]+)([+\_\.\-{1}])?([a-zA-Z0-9]+)\@([a-zA-Z0-9]+)([\.])([a-zA-Z\.]+)/;
}
@@ -104,6 +106,19 @@ AccountValidator.prototype.messageForInvalidLicenseTimerPassword = function(text
}
// email ID
AccountValidator.prototype.isValidEmailAddress = function(email) {
if(!this.patternEmailAddress.test(email))
return false;
return true;
}
AccountValidator.prototype.messageForInvalidEmailAddress = function(email) {
return "유효하지 않은 이메일 주소입니다. 올바른 이메일 주소를 입력해주세요.";
}
AccountValidator.MAESTRO_ID_LENGTH_MINIMUM = 4;
+12 -2
View File
@@ -76,6 +76,13 @@ function onErrorMaestroPW(message) {
$("#password").focus();
}
function onErrorEmailAddress(message) {
showErrorMessage(message, "error");
$("#email").focus();
$("#email").select();
}
function checkData() {
maestroName = $("#maestro_name").val();
if(maestroName.length === 0) {
@@ -104,18 +111,21 @@ function checkData() {
showErrorMessage("이메일을 입력해 주세요.", "error");
$("#email").focus();
return;
} else if(!accountValidator.isValidEmailAddress(email)) {
onErrorEmailAddress(accountValidator.messageForInvalidEmailAddress(email));
return;
}
var selctedObject = $("input[name=account_type_radio]:checked");
selectedAccountTypeValue = selctedObject.val();
if(selectedAccountTypeValue === undefined) {
showErrorMessage("학생 수를 선택해 주세요. (※ 모두 유료 결제를 하셔야 하는 서비스입니다)", "error");
showErrorMessage("학생 수를 선택해 주세요. (※ 계정 등록에 필요한 결제 비용도 함께 확인해주세요)", "error");
return;
}
var isCheckAcceptClauses = $("#check_accept_clauses").is(":checked");
if(!isCheckAcceptClauses) {
showErrorMessage("약관을 읽고, 위에 있는 체크 버튼을 눌러 주세요.", "error");
showErrorMessage("약관 내용을 살펴보신 후, [등록 신청] 버튼 바로 위에 있는 약관 동의 항목을 체크해주세요.", "error");
$("#check_accept_clauses").focus();
return;
}