Skip to content

Commit be33e78

Browse files
committed
add comment to login
1 parent ea33491 commit be33e78

1 file changed

Lines changed: 10 additions & 5 deletions

File tree

assets/jsClass/js/login.js

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,11 @@ function login(){
6969
showLoader(true);
7070
axios.get("http://localhost:3000/account")
7171
.then((response) => {
72+
showLoader(false);
73+
// check if the username and password is correct
7274
for (let index in response.data){
7375
if ((response.data[index].username === username.value.trim()) &&
74-
(response.data[index].password === password.value)){
75-
showLoader(false);
76+
(response.data[index].password === password.value)){
7677
result.innerHTML = "Welcome <span>" + response.data[index].name + "</span><br>" + "You have successfully logged in";
7778
username.style.display = "none";
7879
password.style.display = "none";
@@ -277,11 +278,13 @@ function signup(){
277278
const password = document.getElementById("password");
278279
const loginBtn = document.getElementById("loginBtn");
279280
const signupBtn = document.getElementById("signupBtn");
280-
const loginContainer = document.getElementById("loginContainer");
281+
const loginContainer = document.getElementById("loginContainer");
282+
// run if the first time click on "Create account" button, after that this button change name to "Sign up"
281283
if (!isSignup){
282284
isSignup = true;
283285
username.value = "" ;
284286
password.value = "" ;
287+
// add 2 input element for name and mobile number
285288
let nameInput = document.createElement("input");
286289
let mobileInput = document.createElement("input");
287290
nameInput.className="inputText";
@@ -298,6 +301,7 @@ function signup(){
298301
loginBtn.style.display = "none" ;
299302
loginHeader.textContent = "Create New Account";
300303
signupBtn.textContent = "Sign up";
304+
// hide "sign up" button so that the user completes all the Items first.
301305
document.getElementById("buttonContainer").style.visibility="hidden";
302306
document.getElementById("result").textContent = "Complete all the Items to create an Account";
303307

@@ -309,7 +313,8 @@ function signup(){
309313

310314
// wait for select post method
311315
showCreateNewAccount(2);
312-
316+
317+
// click on "sign up" button after that select the Post Method
313318
} else if (isSignup){
314319
isSignup = false;
315320
const name = document.getElementById("name");
@@ -344,7 +349,7 @@ function validate(element){
344349
document.getElementById("buttonContainer").style.visibility="hidden";
345350
document.getElementById("result").textContent = "Complete all the Items to create an Account";
346351
} else {
347-
const mobileRegExp = /^\d+$/;
352+
const mobileRegExp = /^\d+$/; // Just Numbers Allowed
348353
if(element.target.value.match(mobileRegExp)){
349354
element.target.style.backgroundColor = "";
350355
validateMobile = true;

0 commit comments

Comments
 (0)