From 618bc4453ac45d5ac82741458a2152a0978a1ffb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E1=84=8B=E1=85=A2=E1=84=91=E1=85=B3=E1=86=AF=20=E1=84=82?= =?UTF-8?q?=E1=85=A9=E1=84=90=E1=85=B3=E1=84=87=E1=85=AE=E1=86=A8?= Date: Sat, 22 Dec 2018 18:18:09 +0900 Subject: [PATCH] Add: Email validator --- src/web/js/lib/account_validator.js | 15 +++++++++++++++ src/web/module/maestro_section_register.html | 14 ++++++++++++-- 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/src/web/js/lib/account_validator.js b/src/web/js/lib/account_validator.js index 607c67e..c00a110 100644 --- a/src/web/js/lib/account_validator.js +++ b/src/web/js/lib/account_validator.js @@ -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; diff --git a/src/web/module/maestro_section_register.html b/src/web/module/maestro_section_register.html index b03228d..1bf5c81 100644 --- a/src/web/module/maestro_section_register.html +++ b/src/web/module/maestro_section_register.html @@ -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; }