Skip to content

Instantly share code, notes, and snippets.

@rmrotek
Created January 11, 2019 15:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save rmrotek/65f0bfd5ab041715329bb95d3b661b3d to your computer and use it in GitHub Desktop.
Save rmrotek/65f0bfd5ab041715329bb95d3b661b3d to your computer and use it in GitHub Desktop.
random code
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