webdns.dev.html/signup.js

26 lines
976 B
JavaScript

var sent = false;
function signup() {
if (sent) return;
var email = emailAddr.value;
if (!validateEmail(email)) return;
mailbtn.classList.add("fa-clock");
mailbtn.classList.remove("mail-button");
mailbtn.blur();
console.log("Sending request...");
sent = true;
var req = new XMLHttpRequest();
req.onload = function () {
console.log(this.status + ": " + this.responseText);
mailbtn.classList.remove("fa-clock");
mailbtn.classList.add("fa-" + (this.status === 200 ? "check" : "times"));
};
req.open("POST", "https://whserver.dforms.point0.tech/589550963468140574");
req.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
req.send("email=" + encodeURIComponent(email));
}
function validateEmail(email) {
var re = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
return re.test(String(email).toLowerCase());
}