我有一个网站,我正在尝试使我的(额外费用)复选框,然后继续结帐与贝宝。点击复选框后,还会为总价添加额外的钱(不确定是否会影响任何内容)。我也找不到复选框的name =字段,所以我使用了id =,我确信它是完全错误的。对不起,我对此非常陌生。所需的复选框的JavaScript代码
另请注意 - 在我的复选框表单之后,我必须通过点击一本书的另外2页按钮才能到达提交结账按钮......不确定这是否会阻止任何工作正常? -
我已经添加了以下我的自定义CSS:
<form action="../" onsubmit="if (this.package-44.checked == false) { alert ('You didn\'t choose any of the checkboxes!'); return false; } else { return true; }">
<p><input type="checkbox" id="package-44" value="add" required="required" /></p>
<p><input type="submit" name="woocommerce_checkout_place_order" value="Proceed to PayPal" required="required" /></p>
</form>
我张贴这在我的主题footer.php:
$('#formTemplate').submit(function() {
if (!attributeSupported("required") || ($.browser.safari)) {
//If required attribute is not supported or browser is Safari (Safari thinks that it has this attribute, but it does not work), then check all fields that has required attribute
$("#formTemplate [required]").each(function(index) {
if (!$(this).val()) {
//If at least one required value is empty, then ask to fill all required fields.
alert("Please fill all required fields.");
return false;
}
});
}
return false; //This is a test form and I'm not going to submit it
});
我也改变了输入<required="required" />
上我的复选框输入的后端。这仍然没有阻止我继续结帐。 更多的帮助表示赞赏。
不适用于[IE <10](http://caniuse.com/#search=required),这可能是一个问题 – empiric
是的正确,我试过了,它仍然没有工作? – Harmonyll2
尝试
–