<script runat="server">
Sub user(source As object,args As ServerValidateEventArgs)
if len(args.Value)<8 or len(args.Value)>16 then
args.IsValid=false
else
args.IsValid=true
end if
End Sub
</script>
<html>
<body>
<form runat="server">
<asp:Label runat="server" Text="名:" />
<asp:TextBox id="txt1" runat="server" />
<asp:Button Text="提交" runat="server"/>
<br />
<asp:Label id="mess" runat="server"/>
<br />
<asp:CustomValidator
ControlToValidate="txt1"
OnServerValidate="user"
Text="介于 8 到 16 !"
runat="server"/>
</form>
</body>
</html>