-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
21 lines (20 loc) · 708 Bytes
/
script.js
File metadata and controls
21 lines (20 loc) · 708 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
const name = document.getElementById('name')
const password = document.getElementById('password')
const form = document.getElementById('form')
const errorElement = document.getElementById('error')
form.addEventListener('submit', (e)=>{
let messages=[];
if(password.value.length<=6){
messages.push('Password must be longer than 6 characters.')
}
if(password.value.length>=20){
messages.push('Password must be shorter than 20 characters.')
}
if(password.value==='password'){
messages.push('Password cannot be password.')
}
if(messages.length>0){
e.preventDefault()
errorElement.innerText=messages.join(', ');
}
})