繁体   English   中英

提交字段,除非选择了“隐藏”的必填字段,否则不填写

[英]Submit field without completing “hidden” mandatory fields unless they are selected

我有一个会员注册表,仅在进行某些选择时才需要提供付款明细。

如果我是会员,并且只想注册自己,那么它不会花我任何钱,因此不需要付款。 在这种情况下,我希望能够在不填写“付款明细”的情况下提交表单,因为使用有人帮助我的一些JavaScript可以通过任何方式对它们进行隐藏。

但是,如果我想带一两个客人,我可以选择“会员+ XX个客人”。 仅当选择了其他客人时,我才希望出现并处理“付款选项”。

您可以在此处查看我正在处理的页面: http : //www.faa.net.au/test/femmes-member-form.html

知道我该怎么做吗? 任何帮助表示赞赏。

这是使用Adobe Business Catalyst的方法,即使我已经标记了这些单词,以防万一它不清楚。 谢谢。

您的验证已通过HTML的以下功能完成:

function checkWholeForm65983(theForm) {
var why = "";
if (theForm.FirstName) why += isEmpty(theForm.FirstName.value, "First Name");
if (theForm.LastName) why += isEmpty(theForm.LastName.value, "Last Name");
if (theForm.EmailAddress) why += checkEmail(theForm.EmailAddress.value);
if (theForm.HomePhone) why += isEmpty(theForm.HomePhone.value, "Home Phone Number");
if (theForm.CaptchaV2) why += captchaIsInvalid(theForm, "Enter Word Verification in box below", "Please enter the correct Word Verification as seen in the image");
if (theForm.CAT_Custom_257593) why += isEmpty(theForm.CAT_Custom_257593.value, "Member Number");
if (theForm.CAT_Custom_255275) why += checkDropdown(theForm.CAT_Custom_255275.value, "Available Dates");
if (theForm.CAT_Custom_255276 ) why += checkDropdown(theForm.CAT_Custom_255276.value, "Number of Tickets");
if (theForm.CAT_Custom_255277) why += checkSelected(theForm.CAT_Custom_255277, "Payment Method");
if (theForm.CAT_Custom_255279) why += isEmpty(theForm.CAT_Custom_255279.value, "Questions / Message or Other Information");
if (why != "") {
    alert(why);
    return false;
}
if (submitcount65983 == 0) {
    submitcount65983++;
    theForm.submit();
    return false;
} else {
    alert("Form submission is in progress.");
    return false;
}
}

特别是CAT_Custom_255277是重复检查是否已填写“付款选项”的内容。 如果选择了Member = $0我们将忽略此检查。 所以尝试这样的事情:

if (theForm.CAT_Custom_255277 && theForm.CAT_Custom_255276.value != "1") 
    why += checkSelected(theForm.CAT_Custom_255277, "Payment Method");

之所以将其设置为"1"是因为您将Member = $0选项设置为"1"

<option value="1">Member = $0</option>

希望这有效!

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM