Skip to content
This repository has been archived by the owner on Sep 12, 2018. It is now read-only.

Commit

Permalink
Signup: Fix does not remove validate messages for password and passwo…
Browse files Browse the repository at this point in the history
…rd confirm

- Change to realtime check
- Change to relative check password and password confirm
  • Loading branch information
insanehong committed Apr 10, 2015
1 parent e4acd2e commit c2836e5
Showing 1 changed file with 37 additions and 8 deletions.
45 changes: 37 additions & 8 deletions public/javascripts/service/yobi.user.SignUp.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,10 @@
* attach event
*/
function _attachEvent(){
htElement.welInputLoginId.focusout(_onBlurInputLoginId);
htElement.welInputEmail.focusout(_onBlurInputEmail);
htElement.welInputPassword.focusout(_onBlurInputPassword);
htElement.welInputPassword2.focusout(_onBlurInputPassword);
htElement.welInputLoginId.on('focusout', _onBlurInputLoginId);
htElement.welInputEmail.on('focusout', _onBlurInputEmail);
htElement.welInputPassword.on('keyup', _onValidInputPassword);
htElement.welInputPassword2.on('keyup', _onValidInputPasswordCheck);
}

function _onBlurInputLoginId(){
Expand All @@ -86,22 +86,51 @@
}

function _onBlurInputEmail(){

var welInput = $(this);

if(welInput.val() !== ""){
if($.trim(welInput.val()) !== ""){
doesExists(welInput, htVar.sEmailCheckUrl);
}
}

function _onBlurInputPassword(){
htVar.oValidator._validateForm();
function _onValidInputPassword(){

clearTimeout(htVar.oDelay);

htVar.oDelay = setTimeout(checkPassword, 300);
}

function checkPassword() {
hideErrorMessage(htElement.welInputPassword);

if($.trim(htElement.welInputPassword.val()).length < 4) {
showErrorMessage(htElement.welInputPassword, Messages("validation.tooShortPassword"));
}

checkPasswordConfirm();
}

function _onValidInputPasswordCheck() {
clearTimeout(htVar.oDelay);

htVar.oDelay = setTimeout(checkPasswordConfirm, 200);
}

function checkPasswordConfirm() {
hideErrorMessage(htElement.welInputPassword2);

if (htElement.welInputPassword2.val() !== htElement.welInputPassword.val()) {
showErrorMessage(htElement.welInputPassword2, Messages("validation.passwordMismatch"));
}
}

/**
* @param {Wrapped Element} welInput
* @param {String} sURL
*/
function doesExists(welInput, sURL){

$.ajax({
"url": sURL + welInput.val()
}).done(function(htData){
Expand All @@ -128,7 +157,7 @@
];

htVar.oValidator = new FormValidator('signup', aRules, _onFormValidate);
htVar.oValidator.registerCallback('check_loginId', _onValidateLoginId)
htVar.oValidator.registerCallback('check_loginId', _onValidateLoginId);

// set error message
htVar.oValidator.setMessage('check_loginId', Messages("validation.allowedCharsForLoginId"));
Expand Down

0 comments on commit c2836e5

Please sign in to comment.