customvalidator

代碼:

<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>    

 

<!DOCTYPE html>

<html>

<body>

 

<form runat="server">

<asp:Label runat="server" Text="Enter a username: " />

<asp:TextBox id="txt1" runat="server" />

<asp:Button Text="Submit" runat="server"/>

<br>

<asp:Label id="mess" runat="server"/>

<br>

<asp:CustomValidator

ControlToValidate="txt1"

OnServerValidate="user"

Text="A username must be between 8 and 16 characters!"

runat="server"/>

</form>

 

</body>

</html>

結(jié)果:

相關(guān)文章
亚洲国产精品第一区二区,久久免费视频77,99V久久综合狠狠综合久久,国产免费久久九九免费视频