以下是我的代码无法在asp.net用户控件中进行asp:Textbox
所需的asp:LinkButton
验证
如果从asp:LinkButton
更改为asp:按钮,则所有HTML5 validators
都正常工作。但我必须在我的项目中使用asp:LinkButton
。
ASPX
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Forgot-Password.aspx.cs" validateRequest="false" enableEventValidation="false" Inherits="Test.Forgot_Password" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajaxToolkit" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<link href="../Content/bootstrap.min.css" rel="stylesheet" />
<script src="../Scripts/bootstrap.min.js"></script>
<script src="../Scripts/jquery-1.9.1.min.js"></script>
<script src="../Scripts/jquery.validate.min.js"></script>
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:PlaceHolder ID="PlaceHolder1" runat="server"></asp:PlaceHolder>
</form>
</body>
</html>
ASCX
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="Forgot-Password.ascx.cs" Inherits="Test.Modules.Forgot_Password" %>
<form id="forgot-form" role="form" autocomplete="off" class="form" method="post">
<div class="form-group">
<div id="emaild" class="input-group">
<span class="input-group-addon"><i class="glyphicon glyphicon-envelope color-blue"></i></span>
<asp:TextBox ID="email" placeholder="email address" CssClass="form-control" name="email" type="email" runat="server" tooltip="Please enter your e-mail id." minlength="3" required></asp:TextBox>
</div>
</div>
<div class="form-group">
<asp:LinkButton ID="SendPassword" CssClass="btn btn-lg btn-primary btn-block" runat="server" OnClick="SendPassword_Click">Send Password</asp:LinkButton>
</div>
</form>
<script>
$(document).ready(function (e) {
$('#<%=SendPassword.ClientID%>').click(function () {
$("#forgot-form").validate();
});
});
</script>
我试过了
1.当我使用asp:LinkButton
时,我使用了valid()
- 没有使用
$(document).ready(function (e) {
$('#<%=SendPassword.ClientID%>').click(function () {
return $("#forgot-form").valid();
});
});
2。在asp:LinkButton
我使用CausesValidation="false"
但没有运气
3.添加Rule
- 没有运气
$(document).ready(function (e) {
$('#<%=SendPassword.ClientID%>').click(function () {
$("#forgot-form").validate({
rules: {
<%=email.ClientID%>: {
required: true,
email: true
}
}
});
});
});
请提出我在这里缺少的内容。