【问题标题】:Magento 1.7 / How to delete "This is a required field" when start typing?Magento 1.7 / 开始输入时如何删除“这是必填字段”?
【发布时间】:2017-01-24 00:54:47
【问题描述】:

我想在用户开始输入时从产品选项文本字段中隐藏(删除)消息“这是一个必填字段”。

这是我目前的尝试:

document.getElementsByClassName("product-custom-option").onclick = function(){
    document.getElementById("advice-required-entry-select_"+this.id).remove();
};

但它不起作用。

【问题讨论】:

  • 你需要使用另一个事件。
  • 请更明确地定义“但它不起作用”

标签: javascript jquery magento prototype


【解决方案1】:

对文本字段使用 onfocus、onblur、onkeypress 而不是 onclick

【讨论】:

    【解决方案2】:

    您可以为该产品设置是否需要管理员。或者您只需从该自定义选项字段中删除所需的条目类

    【讨论】:

      【解决方案3】:
      function req(option_id) {
      var e = document.getElementById("select_"+option_id);
      var selectedValue = e.options[e.selectedIndex].text;
      if(selectedValue == '-- Please Select --') {
          document.getElementById("select_"+option_id).className = "required-entry product-custom-option validation-failed";
          if(document.getElementById("advice-required-entry-select_"+option_id)) {
              if(document.getElementById("advice-required-entry-select_"+option_id).style.display == 'none') {
                  document.getElementById("advice-required-entry-select_"+option_id).style.display = 'block';
              }
          }
      }
      if(selectedValue && selectedValue !== '-- Please Select --') {
          document.getElementById("select_"+option_id).className = "required-entry product-custom-option";
          //document.getElementById("advice-required-entry-select_"+option_id).remove();
          if(document.getElementById("advice-required-entry-select_"+option_id)) {
              document.getElementById("advice-required-entry-select_"+option_id).style.display = 'none';
          }
      }
      

      }

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2013-03-09
        • 1970-01-01
        • 2018-09-01
        • 1970-01-01
        相关资源
        最近更新 更多