rangevalidator 2

代码:

<script  runat="server">

Sub submit(sender As Object, e As EventArgs)

If Page.IsValid Then

   lbl1.Text="Page is valid."

Else

   lbl1.Text="Page is not valid!!"

End If

End Sub

</script>

 

<!DOCTYPE html>

<html>

<body>

 

<form runat="server">

Enter a number from 1 to 100:

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

<br><br>

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

<br><br>

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

<br>

<asp:RangeValidator

ControlToValidate="tbox1"

MinimumValue="1"

MaximumValue="100"

Type="Integer"

EnableClientScript="false"

Text="The value must be from 1 to 100!"

runat="server" />

</form>

 

</body>

</html>

结果:

相关文章