Created
January 11, 2019 15:23
-
-
Save rmrotek/65f0bfd5ab041715329bb95d3b661b3d to your computer and use it in GitHub Desktop.
random code
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var emailForm = document.getElementById('emailForm') | |
function handleForm(event) { | |
event.preventDefault(); | |
var checkBox = document.getElementById("myCheck"); | |
var myRemind = document.getElementById("remind"); | |
var getEmail = document.getElementById('getEmail'); | |
var emailValue = getEmail.value; | |
var testAt = emailValue.indexOf('@'); | |
var testDot = emailValue.indexOf('.'); | |
var checkboxIsChecked = false | |
var emailIsCorrect = false | |
if (checkBox.checked === true) { | |
myRemind.style.display = "none"; | |
checkboxIsChecked = true | |
console.log('checkbox succeed', checkboxIsChecked) | |
} else { | |
myRemind.style.display = "block"; | |
console.log('checkbox failed', checkboxIsChecked) | |
} | |
if (testAt > 0 && testDot > 0) { | |
emailIsCorrect = true | |
console.log('email succeed', emailIsCorrect) | |
} else { | |
console.log('email failed', emailIsCorrect) | |
} | |
if(checkboxIsChecked && emailIsCorrect){ | |
// return location.replace("https://www.wp.pl/") | |
return console.log('redirecting...') | |
} | |
} | |
emailForm.addEventListener('submit', handleForm) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment