我崩潰了,因為我無法在我的郵件列表表單中執行我的選擇的自定義驗證。我有另一個字段,可以在無效時進行驗證,但在選擇中它似乎不起作用。讓我告訴你我的代碼。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; }}
我無法驗證此選擇
莫回無
2023-02-17 16:48:20