1

当我从函数调用我的函数时,我在 jquery 中的代码出现问题,它显示循环警报消息和错误消息“未捕获的错误:超过最大堆栈调用”。

这是我的代码:

@html:

<div class="main">
        @using (Html.BeginForm("AvailabilitySave", "Worker", FormMethod.Post, new { id = "AvailabilityForm" }))

        {

            <input type="hidden" id="availabilityId" name="workerId" value="@workerId" />

          <p>
                    <label for="dllAvailableDay">
                        <abbr title="This is a required field.">
                            <em><font color="red">*</font></em></abbr>
                        Available Day</label>
                    <span>
                        @Html.DropDownList("dllAvailableDay", new SelectList(ViewBag.availableDayList, "ID", "Display_Value", workerAvailableDay), "[Please Select]",
              new Dictionary<string, object>
                    {
                        {"class","validate[required] inputLong"}
                    })
                    </span>
                </p>
                <p>
                    <label for="TpStartTime">
                        <abbr title="This is a required field.">
                            <em><font color="red">*</font></em></abbr>
                        Start Time</label>
                    <span>
                        <input id="tpStartTime" name ="tpStartTime" value="@workerStartTime" 
                               style="padding:0 0 0 0 !important" />
                    </span>
                </p>

                <p>
                    <label for="TpEndTime">
                        <abbr title="This is a required field.">
                            <em><font color="red">*</font></em></abbr>
                        End Time</label>
                    <span>
                        <input id="tpEndTime" name ="tpEndTime" value="@workerEndTime" 
                                style="padding:0 0 0 0 !important"/>
                    </span>
                  </p>
    <p>
                    <label>
                        Anytime</label>
                    <span>
                        <input type="checkbox" name="chAnytime" id="chAnytime" value="true" checked="checked" />
                    </span>
                </p>
                <p>
                    <span>
                        <input type="submit" id="addAvailBtn" class="styledButton" value="Add" />
                    </span>
                </p>
}
</div>

我的js:

$("#AvailabilityForm").on('submit', function (e) 
    {
        var gvDetDDLs = $('#availabilityGrid').find("input[name=dllEditAvailableDay]");
        $.each(gvDetDDLs, function () {
            var duplicateExists = false;
            var ddlDay = $("#dllAvailableDay option:selected").text();

            var currVal = $(this).val();
            gvDetDDLs.not(this).each(function () {
                e.stopPropagation();
                if (ddlDay == currVal) {
                    duplicateExists = true;
                    alert("Duplicate entry is not allowed");
                    $(this).focus();
                    return false;
                }
            }
                );
        }
        );
        return true;

    }
);

我的情况是我想在您单击提交按钮时发送一条消息,并且它不会保存以防止重复输入。

请帮我解决这个问题???

谢谢

4

0 回答 0