提交字段而不填写“隐藏”必填字段,除非选中它们

时间:2013-05-16 05:10:17

标签: javascript forms webforms adobe business-catalyst

我有会员登记表,只有在做出某些选择时才需要付款明细。

如果我是会员且只是想自己注册,那么我不需要花费任何费用,因此无需付款。在这种情况下,我希望能够在不完成付款详细信息的情况下提交表单,因为他们使用我有人帮助我的一些javascript对我隐藏。

但是,如果我想带一两位客人,我可以选择会员+ XX宾客。仅当选择了其他访客时,我才希望显示和处理付款选项。

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

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

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

1 个答案:

答案 0 :(得分:2)

您的验证正在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>

希望这有效!

相关问题