regularexpressionvalidator
代碼:
<script runat="server">sub submit(sender As Object, e As EventArgs)
if Page.IsValid then
lbl.Text="The page is valid!"
else
lbl.Text="The page is not valid!"
end if
end sub
</script>
<!DOCTYPE html>
<html>
<body>
<form runat="server">
Enter a US zip code:
<asp:TextBox id="txtbox1" runat="server" />
<br><br>
<asp:Button text="Submit" OnClick="submit" runat="server" />
<br><br>
<asp:Label id="lbl" runat="server" />
<br>
<asp:RegularExpressionValidator
ControlToValidate="txtbox1"
ValidationExpression="\d{5}"
EnableClientScript="false"
ErrorMessage="The zip code must be 5 numeric digits!"
runat="server" />
</form>
</body>
</html>
結果:
相關文章
- ASP.NET
- ASP.NET RangeValidator 控件
- ASP.NET Panel 控件
- ASP.NET Style 控件
- ASP.NET XML 控件
- WebSecurity CurrentUserName 屬性
- WebSecurity IsConfirmed 方法
- C# 實例 Array 數(shù)組
- ASP.NET CheckBox Checked 屬性
- ASP.NET CheckBoxList CellPadding 屬性
- ASP.NET AdRotator Target 屬性
- ASP.NET Image AlternateText 屬性
- ASP.NET Style Width 屬性
- ASP.NET TableCell Wrap 屬性
- ASP.NET ClientID 屬性
- 檢查用戶是否仍然與服務器相連
- 返回行數(shù)
- 取得指定驅動器的根文件夾
- 此文件何時被修改
- 指定的鍵存在嗎?