【发布时间】:2020-01-03 12:40:32
【问题描述】:
大家好,我正在处理我下载的插件的代码,目标是根据用户的选择隐藏 Woocommerce 结算结帐表单的某些字段,创建此插件的开发人员已实现一个名为:billing_invoice_type 的可选字段,然后是一个 if 循环,它承认当这个字段等于一个值时,必须生成一些东西的各种可能性,此时我已经实现了能够隐藏字段的指令我感兴趣的:
var wcpdf_IT;
function wcpdf_IT_billing_customer_type_change(wcpdf_IT_country_selected) {
jQuery("#billing_cf_field label").html(wcpdf_IT.lblCommon);
jQuery("#billing_cf").attr("placeholder", wcpdf_IT.txtCommon);
if(jQuery("#billing_invoice_type").val() === "receipt" ) {
// RIMUOVI LABEL E CAMPO INPUT | NOME DELLA SOCIETÀ
jQuery("#billing_company_field ").hide();
// RIMUOVI LABEL E CAMPO INPUT | CAP
jQuery("#billing_postcode_field ").hide();
// RIMUOVI LABEL E CAMPO INPUT | INDIRIZZO
jQuery("#billing_address_1_field ").hide();
// RIMUOVI LABEL E CAMPO INPUT | APPARTAMENTO / SUITE
jQuery("#billing_address_2_field ").hide();
// RIMUOVI LABEL E CAMPO INPUT | CITTÀ
jQuery("#billing_city_field ").show();
$('#billing_city').removeClass('woocommerce-invalid woocommerce-invalid-required-field');
// RIMUOVI LABEL E CAMPO INPUT | PROVINCIA
jQuery("#billing_state_field ").hide();
jQuery("#billing_cf_field label").html(wcpdf_IT.lblPersonal);
jQuery("#billing_cf").attr("placeholder", wcpdf_IT.txtPersonal);
}
wcpdf_IT_check_PEC();
}
然而,现在的问题不仅仅是让它们出现或隐藏,而是这些默认字段是必需的类型,因此用户在编译阶段看不到它们,但是当他完成编译时出现错误显示在显示屏上是因为他必须填写隐藏字段,所以我必须删除所需的属性。
我尝试了多种方式,通过 Jquery 从我感兴趣但尝试失败的字段中删除了必需的属性。
我该怎么办?
【问题讨论】:
-
你有解决办法吗?如果是,请在此处分享。
标签: jquery wordpress woocommerce