问题:此代码未触发StartValidation function
. 为什么?
<html>
<head>
<script src="/Scripts/jquery-1.7.1.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function () {
$('#frmUp').find("input[type = 'submit']").click(function () {
$('#frmUp').submit();
});
});
function StartValidation() {
return true;
}
</script>
</head>
<body>
<div>
@using (Ajax.BeginForm("UploadRequestFile", "FileUpload", new AjaxOptions
{
HttpMethod = "POST",
OnBegin = "return StartValidation();"
}, new { id = "frmUp" }))
{
<input type="submit" name="Submit" value="Submit" />
}
</div>
</body>
</html>
运行时标记
<form method="post" id="frmUp" data-ajax-method="POST"
data-ajax-begin="return StartValidation();" data-ajax="true"
action="/fileupload/UploadRequestFile?Length=10">
<input type="submit" value="Submit" name="Submit">
</form>