Skip to content

Commit

Permalink
Adding forgotpassword.js
Browse files Browse the repository at this point in the history
  • Loading branch information
AnthonyDeSantiago committed Sep 24, 2023
1 parent 2192d92 commit b714d57
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 6 deletions.
51 changes: 51 additions & 0 deletions public/forgotpassword.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
console.log("forgotpassword.js has loaded!!!");

function showError(input, message) {
const formControl = input.parentElement;
formControl.className = "form-control error";
const small = formControl.querySelector('small');
small.innerText = message
}


// function validateEmail(email) {
// var emailPattern = /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/;
// return emailPattern.test(email);
// }

// function validateUserName(username) {

// }


document.getElementById("password_form").addEventListener("submit", async function (e) {
e.preventDefault();
console.log("button is pressed");

const userEmailElement = document.getElementById("user_email");
const userNameElement = document.getElementById("username");

var userEmail = userEmailElement.value;
var username = userNameElement.value;

var isValid = true;

if (userEmail == '') {
var errorMessage = "Please enter an email address.";
showError(userEmailElement, errorMessage);
isValid = false;
}

if (username == '') {
var errorMessage = "Please enter a username.";
showError(userNameElement, errorMessage);
isValid = false;
}


if (!isValid) {
return false;
}


});
11 changes: 5 additions & 6 deletions public/password_page_1.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<link rel="stylesheet" href="style.css" class="rel">
<script defer src = "sprout.js"></script>
<!-- <script defer src = "sprout.js"></script> -->
<script defer src="forgotpassword.js"></script>
</head>
<body>

Expand All @@ -21,13 +22,13 @@
<form id="password_form">
<div class="form-control">
<label for="email">Email</label>
<input type="email" name="user_email" class="forgot_password_form" placeholder="Email">
<input type="email" name="user_email" class="forgot_password_form" id="user_email" placeholder="Email">
<small>Error Message</small>
</div>

<div class="form-control">
<label for="user_id">Username</label>
<input type="user_id" name="user_id" class="forgot_password_form" placeholder="Username">
<input type="user_id" name="user_id" class="forgot_password_form" id="username" placeholder="Username">
<small>Error Message</small>
</div>

Expand Down Expand Up @@ -79,9 +80,7 @@
</form>

<!-- button -->
<a href="index.html">

</a>


</main>

Expand Down

0 comments on commit b714d57

Please sign in to comment.