function WaitFor() {
    var div = $('<div style="Filter:Alpha(Opacity=50);background-color:#FFE4B5;position:absolute;top:0;left:0;width:100%;height:75%;text-align:center;padding:250px 0 0 0;"><div style="width:280px;border:solid 1px #000;padding:20px 0 20px 0;color:#000;font-weight:bold;">wait for processing......</div></div>');
    $('body').append(div);
}

function AskContinue() {
    if (confirm("Are you sure you want to do it?")) {
                   $("form").submit();
    }
}

@using (Html.BeginForm("ForUpload", "CSOT", FormMethod.Post, new { @enctype = "multipart/form-data",@onsubmit="WaitFor()"}))
{
    <div>
        <fieldset>
            <legend>CSOT Upload File</legend>
            <div class="editor-label">
            TXT File
            </div>
            <div class="editor-label">
            @Html.TextBoxFor(m=>m.TXTFile, new { @type = "file", @style = "width:95%;" })
            <br/>@Html.ValidationMessageFor(m => m.TXTFile)
            </div>

           <div class="editor-label">
            <input type="button" style = "width:200px" onclick="AskContinue()" value="Submit"/>
            </div>       

         </fieldset>
     </div>
}

 

在MVC3中,如果一起使用 Html.ValidationMessageFor 和 onsubmit 时,

其执行顺序是 onclick-if(true)-{$("form").submit()-validate-onsubmit-post}

 

问题:这个时候如果验证不通过,WaitFor 将覆盖在上面,无法编辑。

 

则要对AskContinue作以下修改:

 

if($("form").valid()){

             $("form").submit();

}

其执行顺序是 onclick-if(true)-{validate-if(true)-{$("form").submit()-onsubmit-post}}

 

相关文章:

  • 2022-12-23
  • 2021-11-07
  • 2021-11-02
  • 2021-08-17
  • 2022-02-11
  • 2022-12-23
  • 2022-12-23
  • 2021-11-07
猜你喜欢
  • 2021-06-13
  • 2022-12-23
  • 2021-10-29
  • 2022-12-23
  • 2022-02-14
  • 2022-12-23
  • 2021-12-05
相关资源
相似解决方案