Javascript 未填写“提交”字段;“隐藏的”;必填字段,除非已选中

Javascript 未填写“提交”字段;“隐藏的”;必填字段,除非已选中,javascript,forms,webforms,adobe,business-catalyst,Javascript,Forms,Webforms,Adobe,Business Catalyst,我有一份会员登记表,只有在做出特定选择时才需要支付详细信息 如果我是会员,只是想注册自己,它不会花费我任何东西,所以不需要付款。在本例中,我希望能够在不填写付款详细信息的情况下提交表单,因为这些信息是使用一些javascript隐藏的,我让别人帮了我 但是,如果我想带一两位客人,我可以选择会员+XX位客人。仅当选择了其他客人时,我才希望显示并处理付款选项 您可以在此处看到我正在处理的页面: 你知道我该怎么做吗?感谢您的帮助 这是在使用AdobeBusinessCatalyst,尽管我已经标记了这

我有一份会员登记表,只有在做出特定选择时才需要支付详细信息

如果我是会员,只是想注册自己,它不会花费我任何东西,所以不需要付款。在本例中,我希望能够在不填写付款详细信息的情况下提交表单,因为这些信息是使用一些javascript隐藏的,我让别人帮了我

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

您可以在此处看到我正在处理的页面:

你知道我该怎么做吗?感谢您的帮助


这是在使用AdobeBusinessCatalyst,尽管我已经标记了这些词,以防不清楚。谢谢。

您的验证正在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”
,是因为您的
成员=$0
选项设置为
“1”

Member=$0

希望这能奏效

使用
if
语句查看是否选择了某些内容。顺便说一句,请记住始终在服务器上验证相同的输入-您不能依赖于客户端/JavaScript@Ian我如何使用Adobe Business Catalyst做到这一点?对用户隐藏的支付选项具体在哪里?您正在使用jquery,这样您就可以通过执行
.find(“:selected”)
来了解用户选择了什么。因此,请检查他们是否选择了其他来宾。@如果您选择了票数下拉列表,您将看到第一个选项是仅会员,然后是会员+1来宾,等等。添加选择来宾时,将显示付款选项。请参考我的链接上面的表格。
<option value="1">Member = $0</option>