zoukankan      html  css  js  c++  java
  • 避免表单多次提交

    1:提交后将Submit按钮设为Disable

    <div id="SpecialBrokerageEdit">
        @using (Html.BeginForm("AddSpecialBrokerage", "BrokerageStandard", FormMethod.Post, new { id = "frmSpecialBrokerageEdit" }))
        {
            @Html.HiddenFor(m => m.SpBrokerageStdId)
            @Html.HiddenFor(m => m.SpecialBrokerageId)
                 <table>
                <tr>
                    <td>@Html.LabelFor(m => m.SpSiteId)</td>
                    <td>
                        @Html.TextBoxFor(m => m.SpSiteId)
                        @Html.ValidationMessageFor(m => m.SpSiteId)
                    </td>
                </tr>
                  <tr>
                    <td>
                        <label>佣金分配:</label>
                    </td>               
                </tr>
                <tr>
                    <td>@Html.LabelFor(m => m.SpMediaPercent)</td>
                    <td>
                        @Html.TextBoxFor(m => m.SpMediaPercent)<label  name="SpPercentTypeLog">元</label>
                        @Html.ValidationMessageFor(m => m.SpMediaPercent)
                    </td>
                </tr>
                <tr>
                    <td>@Html.LabelFor(m => m.SpPlatformPercent)</td>
                    <td>
                        @Html.TextBoxFor(m => m.SpPlatformPercent)<label name="SpPercentTypeLog">元</label>
                        @Html.ValidationMessageFor(m => m.SpPlatformPercent)
                    </td>
                </tr>
            </table>
            <div class="buttoncontainer">
                <input style="50px;height:30px;" type="submit" value="确定" id="btnspecialBrokerageSave" />
                <input style="50px;height:30px;" type="button" value="取消" id="btnspecialBrokerageCancel" />
            </div>
        }
    </div>
    
        var options = {
            beforeSubmit: function () {
                var itemBtn = $("#btnspecialBrokerageSave");
                itemBtn.prop("disabled", "disabled");
                setTimeout(function () {
                    itemBtn.removeAttr("disabled");
                }, 2000);
                return false;
            },
            success: function (data) {
                if (data.Status == 1) {
                    info.btnSearchSpecialBrokerage.click();
                    infoSpecial.btnspecialBrokerageCancel.click();
                } else {
                    alert(data.Message);
                }
            }
        };
        $('#frmSpecialBrokerageEdit').ajaxForm(options);
    
  • 相关阅读:
    弹性盒模型
    CSS3属性
    CSS3选择器
    闭包
    angularjs-select2的使用
    angular 分页插件的使用
    webstorm 破解
    数组和字符串之间的转化
    git 拉取分支代码 合分支
    时间戳转化为时间格式 时间格式转为时间戳
  • 原文地址:https://www.cnblogs.com/Mylimo/p/3770883.html
Copyright © 2011-2022 走看看