const loginI = document.querySelector('.auth_login_input') const passwordI = document.querySelector('.auth_password_input') const BtnAuthorisation = document.querySelector('.btn_authorisation_user') const BtnRegistration = document.querySelector('.btn_regist_header') //Массив недопустимых имволов let ArrayWarningSymbol = ["'", "<", ">", "=", "!", "$", "^"]; let obj = { loginInput:'', passwordInput:'' } let loginCheck=(login)=>{ console.log(login) if(login===''){ alert('Пустой логин!') loginI.style.borderColor = 'red' return false }else{ for(let i = 0; i < ArrayWarningSymbol.length; i++){ if(login.includes(ArrayWarningSymbol[i])){ alert('Недопустимые символы. Допустимо использовать только латиницу и цифры') loginI.style.borderColor = 'red' return false } } loginI.style.borderColor = 'white' return true } } let passwordCheck=(password)=>{ console.log(password) if(password===''){ alert('Пустой пароль!') passwordI.style.borderColor = 'red' return false }else{ for(let i = 0; i < ArrayWarningSymbol.length; i++){ if(password.includes(ArrayWarningSymbol[i])){ alert('Недопустимые символы. Допустимо использовать только латиницу и цифры') passwordI.style.borderColor = 'red' return false } } passwordI.style.borderColor = 'white' return true } } loginI.addEventListener('change', e=>{ obj.loginInput = e.target.value }) passwordI.addEventListener('change', e=>{ obj.passwordInput = e.target.value }) BtnAuthorisation.addEventListener('click', ()=>{ if(loginCheck(obj.loginInput) && passwordCheck(obj.passwordInput)){ $.ajax({ method: "POST", url: "public/authorisation.php", dataType: 'json', data: { login: obj.loginInput, password: obj.passwordInput } }).done(function( obj ) { if('Acces' in obj){ if(obj.Acces === 'AllRight'){ console.log("+"); console.log(obj); window.location.href = 'groups_page.html'; }else{ console.log("-"); window.location.href = 'activation_code_page.html'; } console.log(obj.Acces); }else{ alert(obj.Error) } }); } })