有了必填字段,我可以在不输入数据的情况下提交表单。
相同的 global.asax 文件在另一个站点上用于不显眼的验证。
这是一个HTML:
<p>
<asp:Label runat="server" ID="lblFirstName" AssociatedControlID="txtFirstName">
First name:
<span class="soft">
(required)
</span>
<asp:RequiredFieldValidator runat="server" ID="reqFirstName" ControlToValidate="txtFirstName" CssClass="red label" Text="Required" />
</asp:Label>
<asp:TextBox runat="server" ID="txtFirstName" MaxLength="50" />
</p>
这是 global.aspx
Sub Application_Start(ByVal sender As Object, ByVal e As EventArgs)
Dim Item As New ScriptResourceDefinition
With Item
.Path = "/assets/scripts/jquery-1.7.2.min.js"
.DebugPath = "/assets/scripts/jquery-1.7.2.min.js"
.CdnPath = "//ajax.microsoft.com/ajax/jQuery/jquery-1.7.2.min.js"
.CdnDebugPath = "//ajax.microsoft.com/ajax/jQuery/jquery-1.7.2.min.js"
End With
ScriptManager.ScriptResourceMapping.AddDefinition("jquery", Item)
End Sub