From 2e96f1d3efeff9e58bf5e9c26507afe0a1f73857 Mon Sep 17 00:00:00 2001 From: parkhabit Date: Fri, 8 Dec 2017 11:34:12 +0000 Subject: [PATCH] fixed password validation on front end relates to #74 --- public/login.js | 27 +++------------------------ 1 file changed, 3 insertions(+), 24 deletions(-) diff --git a/public/login.js b/public/login.js index 5b395ef..a29dd41 100644 --- a/public/login.js +++ b/public/login.js @@ -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); -} \ No newline at end of file +});