亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

我無法驗證此選擇

我無法驗證此選擇

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

1 回答

?
梵蒂岡之花

TA貢獻1900條經驗 獲得超5個贊

這里:


            function countryError() {

              

                var f = document.forms["mlist-form"]["COUNTRY"];

              var country = f.options[f.selectedIndex].value;

                if (country == "") {

                    document.getElementById("country-error-label").innerHTML = "Country is required.";

                    document.getElementById("country-error-label").style.display = "block !important";

                    return false;

                }

            }

一個工作示例


查看完整回答
反對 回復 2023-02-17
  • 1 回答
  • 0 關注
  • 96 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號