我有以下内容
<form action="<%=Url.Action("PasswordDetails",new{Controller = "User"}) %>" method="post" name="PasswordForm" id="PasswordForm" enctype="multipart/form-data">
然而,$("#PasswordForm").submit(function() {
if (validate())
return true;
else
return false;
});
并未通过。
有什么问题?
答案 0 :(得分:3)
<% using (Html.BeginForm("PasswordDetails", "User", FormMethod.Post, new { id = "PasswordForm" }))
{ %>
答案 1 :(得分:1)
您的视图页应如下所示:
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<% using (Html.BeginForm("PasswordDetails", "User",
FormMethod.Post, new { id = "PasswordForm" }))
{ %>
<input type="password" id="sitepassword" />
<input type="submit" value="Submit" />
<% } %>
</asp:Content>
和你的网站大师这样:
<body>
<div class="page">
<div id="main">
<asp:ContentPlaceHolder ID="MainContent" runat="server" />
<div id="footer">
</div>
</div>
</div>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<script type='text/javascript'>
function validate() {
alert('hello');
}
$(document).ready(function () {
$("#PasswordForm").submit(function () {
if (validate()) return true;
else return false; });
});
</script>
</body>