Skip to content
This repository has been archived by the owner on Apr 4, 2023. It is now read-only.

Commit

Permalink
Fixed some issues in the password.js and signup.js
Browse files Browse the repository at this point in the history
  • Loading branch information
samithaliyanage committed Jan 4, 2017
1 parent 3443a2a commit 6d7e0db
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 17 deletions.
2 changes: 1 addition & 1 deletion app/views/signup.scala.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<label for="userId" class="col-sm-2 control-label">User ID</label>
<div class="col-sm-10">
<input type="text" class="form-control" id="userId" name="userId" placeholder="User ID"
required="true"
required
value="@form.data().get("userId")"
aria-describedby="user-id-feedback-status"/>
<span id="user-id-feedback" class="form-control-feedback" aria-hidden="true"></span>
Expand Down
29 changes: 17 additions & 12 deletions public/javascripts/password.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,21 @@ var checkPasswordStrength = function (password, userId, minPasswordLength, maxPa
return "WEAK_PASSWORD";
};

var matchPasswords = function () {
var passwd = $('#password');
var confirmPasswd = $('#confirmPassword');
var confirmPasswdControlGroup = $('#confirm-password-control-group');
var confirmPasswdFeedback = $('#confirm-password-feedback');
if (passwd.val() !== confirmPasswd.val()) {
confirmPasswordMatch = false;
hasError(confirmPasswdControlGroup, confirmPasswdFeedback);
} else {
confirmPasswordMatch = true;
hasSuccess(confirmPasswdControlGroup, confirmPasswdFeedback);
}

};

var registerPasswordStrengthChecker = function () {
var passwd = $('#password');
var passwdControlGroup = $('#password-control-group');
Expand Down Expand Up @@ -91,22 +106,12 @@ var registerPasswordStrengthChecker = function () {
hasSuccess(passwdControlGroup, passwordFeedback);
warnBlock.html('');
}
matchPasswords();
});
};

var registerPasswordMatcher = function () {
var passwd = $('#password');
var confirmPasswd = $('#confirmPassword');
var confirmPasswdControlGroup = $('#confirm-password-control-group');
var confirmPasswdFeedback = $('#confirm-password-feedback');

confirmPasswd.keyup(function () {
if (passwd.val() !== confirmPasswd.val()) {
confirmPasswordMatch = false;
hasError(confirmPasswdControlGroup, confirmPasswdFeedback);
} else {
confirmPasswordMatch = true;
hasSuccess(confirmPasswdControlGroup, confirmPasswdFeedback);
}
});
confirmPasswd.keyup(matchPasswords);
};
10 changes: 6 additions & 4 deletions public/javascripts/signup.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,20 +149,22 @@ var registerUserIDValidation = function () {

var acknowledgeButtonVisibility = function() {
var acknowledgementCheckBox = $('#acknowledgement');
var submitButton = $('#submit');
if (userIdCorrect && passwordCorrect && validEmailDomain && confirmPasswordMatch && confirmEmailMatch) {
acknowledgementCheckBox.prop("disabled",false);
submitButton.prop("disabled", !acknowledgementCheckBox.prop('checked'));
}else{
acknowledgementCheckBox.prop("disabled",true);
submitButton.prop("disabled",true);
}
};

var triggerAlreadyFilledFields = setTimeout(function() {
var triggerAlreadyFilledFields = function() {
$('input').each(function() {
var elem = $(this);
if (elem.val()) elem.change();
})
}, 250);

};

$(document).ready(function () {
registerUserIDValidation();
Expand All @@ -172,5 +174,5 @@ $(document).ready(function () {
acknowledgeButtonVisibility();
registerPasswordMatcher();
registerPasswordStrengthChecker();
triggerAlreadyFilledFields();
setTimeout(triggerAlreadyFilledFields, 250);
});

0 comments on commit 6d7e0db

Please sign in to comment.