-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
23 lines (20 loc) · 754 Bytes
/
Copy pathscript.js
File metadata and controls
23 lines (20 loc) · 754 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
const form = document.getElementById('form')
const username = document.getElementById('username')
const password = document.getElementById('password')
const errMsg = document.querySelector('.err-msg')
form.addEventListener('submit', event => {
event.preventDefault();
//Store all error messages, which we will show if there is an error
const messages = []
//Check if input is empty
if(username.value === '' || username.value === null) {
messages.push('Username cannot be blank')
}
if(password.value.length < 6) {
messages.push('Password should be at least 6 characters')
}
if(messages.length > 0) {
errMsg.classList.remove('hidden')
errMsg.innerHTML = messages.join(', ')
}
})