【问题标题】: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';
}
}
}