-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdom-login.js
More file actions
33 lines (32 loc) · 910 Bytes
/
dom-login.js
File metadata and controls
33 lines (32 loc) · 910 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
31
32
33
const div = document.getElementById('paragraph');
const btn = document.getElementById('btn');
const username = document.getElementById('username');
const password = document.getElementById('password');
const p = document.createElement('p');
// const body = document.querySelector('body');
function allwork() {
if ((username.value.trim() === '') || (password.value.trim() === '')) {
p.textContent = 'Fill All inputs to login please!';
div.appendChild(p);
} else {
username.value = username.value.trim();
password.value = password.value.trim();
const d = {
username: username.value,
password: password.value
};
login(JSON.stringify(d), result => {
p.textContent = result;
div.appendChild(p);
});
p.textContent = '';
}
}
btn.addEventListener('click', event => {
allwork();
});
function keyy() {
if(event.keyCode == 13 ){
allwork();
}
}