if(window.location.hash == '#authed') { post('/login', {popup: 'false',username: 'q1',password: 'q1',dst: '#'}); } else { document.getElementById('hotspot-root').innerHTML = '
Մնացել է 2 վայրկյան
'; } function validateFormOnSubmit(contact) { reason = ''; reason += validateName(contact.fullname); reason += validateEmail(contact.email); console.log(reason); if (reason.length > 0) { return false; } else { return true; } } function validateName(name) { var error = ''; if (name.value.length == 0) { //name.style.background = 'Red'; document.getElementById('fullname-error').innerHTML = 'The required field has not been filled in'; var error = '1'; } else { //name.style.background = 'White'; document.getElementById('fullname-error').innerHTML = ''; } return error; } function trim(s) { return s.replace(/^\s+|\s+$/, ''); } function validateEmail(email) { var error = ''; var temail = trim(email.value); // value of field with whitespace trimmed off var emailFilter = /^[^@]+@[^@.]+\.[^@]*\w\w$/; var illegalChars = /[\(\)\<\>\,\;\:\[\]]/; if (email.value == '') { //email.style.background = 'Red'; document.getElementById('email-error').innerHTML = 'Please enter an email address.'; var error = '2'; } else if (!emailFilter.test(temail)) { //test email for illegal characters //email.style.background = 'Red'; document.getElementById('email-error').innerHTML = 'Please enter a valid email address.'; var error = '3'; } else if (email.value.match(illegalChars)) { //email.style.background = 'Red'; var error = '4'; document.getElementById('email-error').innerHTML = 'Email contains invalid characters.'; } else { //email.style.background = 'White'; document.getElementById('email-error').innerHTML = ''; } return error; } function post(path, params, method) { method = method || "post"; // Set method to post by default if not specified. // The rest of this code assumes you are not using a library. // It can be made less wordy if you use one. var form = document.createElement("form"); form.setAttribute("method", method); form.setAttribute("action", path); for(var key in params) { if(params.hasOwnProperty(key)) { var hiddenField = document.createElement("input"); hiddenField.setAttribute("type", "hidden"); hiddenField.setAttribute("name", key); hiddenField.setAttribute("value", params[key]); form.appendChild(hiddenField); } } document.body.appendChild(form); form.submit(); } function drawCountDow(t) { if(document.getElementById('cd') && t > 0) { document.getElementById('cd').innerText = t; t--; } if(t > 0) { setTimeout(function (){ drawCountDow(t)},1000); }else { //window.location.href="/login?username=q1&password=q1&dst=#"; post('/login', {popup: 'false',username: 'q1',password: 'q1',dst: '#'}); } } drawCountDow(15);