const openArt = function openArticles() { var artId = this.id; var theURL = 'artshow.jsp?artid=' + artId; var winName = 'Artshow'; var features = 'resizable=yes,width=460,height=750,scrollbars=yes'; window.open(theURL, null, features); }; const checkEnterLogin = function checkEnterLogin(evt) { if ( evt.keyCode == 13) { checkForm(evt); } } const checkForm = function checkFormLogin(evt) { evt.preventDefault(); var res = true; var felmedd = ""; var pnr = trim(document.getElementById('pnr').value); var intpwd = trim(document.getElementById('intpwd').value); var land = ""; var lang = ""; var impcountry = "SWE"; var marke = ""; if (pnr.length < 3) { if (land == impcountry) { felmedd = "Ange personnummer med rätt längd!"; } else if (lang == "sv") { felmedd = "Ange identitet!"; } else if (lang == "fi") { felmedd = "Käyttäjätunnus puuttuu!"; } else { felmedd = "Identity is missing!"; } res = false; marke = "pnr"; } else { if (intpwd < 1) { if (land == impcountry || lang == "sv") { felmedd = "Ange internetkod!"; } else if (lang == "fi") { felmedd = "Salasana puuttuu!"; } else { felmedd = "Password is missing!"; } res = false; marke = "intpwd"; } } if (!res) { alert(felmedd); document.forms["theForm"].elements[marke].focus(); } else { document.forms["theForm"].op.value = 'login'; document.forms["theForm"].submit(); } } function showErrorMsg() { var showAlert = false; if(showAlert) { var errMess = 'null'; alert(errMess); } else if (document.getElementById('errorMsg') && document.getElementById('errorMsg').value.length > 0) { alert(document.getElementById('errorMsg').value); } } window.onload = function () { var artLinks = document.getElementsByClassName("artLink"); Array.from(artLinks).forEach(function (element) { element.addEventListener('click', openArt); }); if (document.getElementById('login')) { document.getElementById('login').addEventListener('click', checkForm); } if (document.forms['theForm'] && document.forms['theForm'].intpwd) { document.forms['theForm'].intpwd.addEventListener("keydown", checkEnterLogin); } showErrorMsg() };