-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathprocedural.js
More file actions
30 lines (22 loc) · 736 Bytes
/
procedural.js
File metadata and controls
30 lines (22 loc) · 736 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
const form = document.getElementById('user-input');
function signUpHandler(event) {
event.preventDefault();
const userNameInput = document.getElementById('username');
const enteredUsername = userNameInput.value;
const passwordInput = document.getElementById('password');
const enteredPassword = passwordInput.value;
if (enteredUsername.trim().length === 0) {
alert('Invalid Input - Username must not be empty!');
return;
}
if (enteredPassword.trim().length <= 5) {
alert('Invalid Input - Password must be of 6 characters or longer!');
return;
}
const user = {
userName: enteredUsername,
password: enteredPassword
};
console.log(`Hello ${user.userName}`);
}
form.addEventListener('submit', signUpHandler);