【问题标题】:Submit field without completing "hidden" mandatory fields unless they are selected提交字段而不填写“隐藏”的必填字段,除非它们被选中
【发布时间】:2013-05-16 05:10:16
【问题描述】:

我有一个会员注册表格,只有在做出特定选择时才需要支付详细信息。

如果我是会员并且只想注册自己,我不会花费任何费用,因此无需付款。在这种情况下,我希望能够在不填写付款详细信息的情况下提交表单,因为使用一些我请人帮助我的 JavaScript 以任何方式对我隐藏它们。

但是,如果我想带一两位客人,我可以选择会员 + XX 位客人。 Only when additional guests are selected do I want the Payment Options to appear and be processed.

你可以在这里看到我正在处理的页面:http://www.faa.net.au/test/femmes-member-form.html

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

这是使用 Adob​​e Business Catalyst,尽管我已经标记了这些词,以防万一不清楚。谢谢。

【问题讨论】:

  • 使用if 语句查看是否选择了某些内容。顺便说一句,请记住始终在服务器上验证相同的输入 - 你不能依赖客户端/JavaScript
  • @Ian 我如何使用 Adob​​e Business Catalyst 做到这一点?
  • 对用户隐藏的付款选项到底在哪里?您正在使用 jquery,因此您可以通过 .find(':selected') 了解用户选择的内容,因此请检查他们是否选择了其他客人。
  • @aug 如果您选择门票数量下拉菜单,您将看到第一个选项是仅限会员,然后是会员 + 1 位客人,等等。当您添加选择一位客人时,会出现付款选项。表格请参考我上面的链接。

标签: javascript forms webforms adobe business-catalyst


【解决方案1】:

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

希望这行得通!

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-03-07
    • 1970-01-01
    • 2018-01-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多