For making field MANDATORY:
Use RequiredFieldValidator
:
<asp:TextBox ID="txtName" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator
ID="RequiredFieldValidator1"
runat="server"
ControlToValidate="txtName"
ErrorMessage="Input Country!"
EnableClientScript="true"
SetFocusOnError="true"
Text="*">
</asp:RequiredFieldValidator>
For Validating Range of Number in TextBox
use RangeValidator
:
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:RangeValidator ID="RangeValidator1" runat="server" ControlToValidate="TextBox1" MaximumValue="200" MinimumValue="100" Type="Integer" ErrorMessage="Please input between 100 to 200.">
</asp:RangeValidator>
Read more about Validations Here
Hope this helps you!
2
solved Range Validation in asp.net [closed]