Skip to content

Commit

Permalink
fixed password validation on front end
Browse files Browse the repository at this point in the history
relates to #74
  • Loading branch information
parkhabit committed Dec 8, 2017
1 parent 1451d49 commit 2e96f1d
Showing 1 changed file with 3 additions and 24 deletions.
27 changes: 3 additions & 24 deletions public/login.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,35 +7,14 @@ var validateLogin = document.getElementById('validateMsgLogin');
var formSubmit = document.getElementById('form-signup');


formSubmit.addEventListener('submit', function(event) {
signupPassword2.addEventListener('input', function(event) {
if (validateSignup.childElementCount > 0) {
validateSignup.removeChild(validateSignup.lastChild);
}
var form_valid = (signupPassword1.value === signupPassword2.value);
if (!form_valid) {
if (signupPassword1.value !== signupPassword2.value) {
var pMsg = document.createElement('p');
var errorMsg = document.createTextNode('Passwords do not match');
pMsg.appendChild(errorMsg);
validateSignup.appendChild(pMsg);
return false;
}
return true;
})


//generic xhr XMLHttpRequest
function request(url, method, cb, body) {
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function() {
if (xhr.readyState === 4) {
if (xhr.status === 200) {
cb(null, JSON.parse(xhr.responseText));
} else {
var errorMessage = JSON.parse(xhr.responseText);
cb("Error" + url + " " + errorMessage);
}
}
};
xhr.open(method, url, true);
xhr.send(body);
}
});

0 comments on commit 2e96f1d

Please sign in to comment.