我崩溃了,因为我无法在我的邮件列表表单中执行我的选择的自定义验证。
我有另一个字段,可以在无效时进行验证,但在选择中它似乎不起作用。
让我告诉你我的代码。
function validate() {
var x = document.forms["mlist-form"]["EMAIL"].value;
if (x == "") {
document.getElementById("email-error").innerHTML = "Email Address is required.";
document.getElementById("email-error").style.display = "block";
return false;
}
document.getElementById("email-error").innerHTML = "Please enter a valid Email Address.";
document.getElementById("email-error").style.display = "block";
}
document.addEventListener('invalid', (function() {
return function(e) {
//prevent the browser from showing default error bubble / hint
e.preventDefault();
// optionally fire off some custom validation handler
// myValidation();
};
})(), true);
function countryError() {
var f = document.forms["mlist-form"]["COUNTRY"].value;
if (f = "") {
document.getElementById("country-error-label").innerHTML = "Country is required.";
document.getElementById("country-error-label").style.display = "block !important";
return false;
}
}
梵蒂冈之花
相关分类