123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- const f9 = (rootId) => {
- const login = 'admin';
- const password = 'qwerty';
-
- const task09block = document.createElement('div');
- const task09title = document.createElement('h2');
- const loginInputId =document.createElement('input');
- const passwordInputId =document.createElement('input');
- const signBtnId =document.createElement('button');
- task09title.innerText = 'Task-09 Login and password';
- task09title.style = "margin-left:auto; margin-right:auto";
- loginInputId.style = 'display:block';
- loginInputId.placeholder = 'Enter login';
- passwordInputId.style = 'margin-top:10px;';
- passwordInputId.placeholder = 'Enter password';
- signBtnId.type = 'button';
- signBtnId.style = 'display:block; margin-top:20px';
- signBtnId.innerText = 'Sign in';
-
- rootId.appendChild(task09block);
- task09block.appendChild(task09title);
- task09block.appendChild(loginInputId);
- task09block.appendChild(passwordInputId);
- task09block.appendChild(signBtnId);
- const pswdInMemory = [];
- const pswdOnScreen = [];
-
- //Замена вводимых символов пароля на экране на звездочки *
- passwordInputId.oninput = () => {
- let pswdInputLength = 0;
- pswdInputLength = passwordInputId.value.split('').length;
- pswdInMemory.push(passwordInputId.value.split('')[pswdInputLength - 1]);
- pswdOnScreen[pswdInputLength-1] = "*";
- passwordInputId.value=pswdOnScreen.join('');
- }
- //Верификация логина и пароля
- signBtnId.onclick = () => {
- const loginInput = loginInputId.value;
- const pswdInput = pswdInMemory.join('');
- let notific='';
- if (loginInput === login) {
- if (pswdInput === password)
- {
- notific = "Congratulations! Correct login & password";
- }
- else {
- notific = "Wrong password";
- }
- } else {
- notific = "Wrong login"
- }
- passwordInputId.value = '';
- pswdInMemory.length = 0;
- pswdOnScreen.length = 0;
- alert(notific);
- };
- }
- f9(root);
- export default f9;
|