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",@οnsubmit="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" οnclick="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}}
转载于:https://www.cnblogs.com/yipeng-yu/archive/2012/05/18/2507335.html