basic mail validity by function
var emailField = document.getElementById("some_id");
emailField.addEventListener('keyup', function (event) {
isValidEmail = emailField.checkValidity();
}
);
// regex
var patt = /[\S]+@[a-zA-Z0-9.]+?\.[a-zA-Z]{1,12}/;
if(!patt.test(url_params["email"]))
{
//bad format
}
/* EventListeners */
nameField.addEventListener("keyup", function(event) {
// fix: no auto in/valid css / force on input empty
if(nameField.value == "")
nameField.setCustomValidity("false")
else
nameField.setCustomValidity("");
});
// validate
el = document.getElementById("errorNoticeBox");
el.innerHTML = "";
if(url_params["name"].length == 0)
{
el.innerHTML += "Name field must not be empty!<br>"
nameField.setCustomValidity("false");
return false;
}else{
nameField.setCustomValidity("");
}
if(url_params["email"].length == 0)
{
el.innerHTML += "Email field must not be empty!<br>"
return false;
}