Simply login form

by Michał Oręziak

HTML

<form id="loginForm">
    <input type="text" id="login" placeholder="Login">
     <input type="text" id="pass" placeholder="Hasło">
     <button type="submit">Zaloguj</button>
</form>
<span id="info"></span>

JavaScript

const creds = {
login: 'micorix',
pass: 'onetwothree'
};
function $(el){
return document.querySelector(el);
}
$('#loginForm').addEventListener('submit', e => {
e.preventDefault();
if($('#login').value == creds.login && $('#pass').value == creds.pass){
$('#info').style.color = "green";
$('#info').innerText = 'Zalogowano';
}else{
$('#info').style.color = "red";
$('#info').innerText = 'Błąd logowania';
}
});