ASP.Net provides validation controls which a rich amount
of validation services that saves your work to make
java script code because at a huge level java script is used to validate client side
validation. for perform validation using java script you must have knowledge of
java script.
But you can perform powerful validation using ASP.net Validation
Controls with knowledge of java script..
RequiredFieldValidator Control
Evaluates the value of an input control to ensure that the user enters a value.
Use the RequiredFieldValidator control to make an input control a mandatory field. The input control fails validation if the value it contains does not change from its initial value when validation is performed. This prevents the user from leaving the associated input control unchanged. By default, the initial value is an empty string (""), which indicates that a value must be entered in the input control for it to pass validation.
Controls :
Property :of validation services that saves your work to make
java script code because at a huge level java script is used to validate client side
validation. for perform validation using java script you must have knowledge of
java script.
But you can perform powerful validation using ASP.net Validation
Controls with knowledge of java script..
RequiredFieldValidator Control
Evaluates the value of an input control to ensure that the user enters a value.
Use the RequiredFieldValidator control to make an input control a mandatory field. The input control fails validation if the value it contains does not change from its initial value when validation is performed. This prevents the user from leaving the associated input control unchanged. By default, the initial value is an empty string (""), which indicates that a value must be entered in the input control for it to pass validation.
Controls :
- Textbox
- ASP Button
- Requirefield Validater
- Label
RequiredFieldValidator
- ControlToValidate="TextBox1"
- ErrorMessage="*"
Aspx page code
<form id="form1" runat="server">
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
;<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server"
ControlToValidate="TextBox1" ErrorMessage="*"></asp:RequiredFieldValidator>
<asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Save" />
<asp:Label ID="Label1" runat="server"></asp:Label>
</form>
Server Side code :
protected void Button1_Click(object sender, EventArgs e)
{
Label1.Text = "Running Server code";
}
RangeValidator Control
Evaluates the value of an input control to determine whether it is between the specified upper and lower boundaries.
The RangeValidator control allows you to check whether a user's entry is between a specified upper and a specified lower boundary. You can check ranges within pairs of numbers, alphabetic characters, and dates. Boundaries are expressed as constants.
<form id="form1" runat="server">
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
;<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server"
ControlToValidate="TextBox1" ErrorMessage="*"></asp:RequiredFieldValidator>
<asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Save" />
<asp:Label ID="Label1" runat="server"></asp:Label>
</form>
Server Side code :
protected void Button1_Click(object sender, EventArgs e)
{
Label1.Text = "Running Server code";
}
RangeValidator Control
Evaluates the value of an input control to determine whether it is between the specified upper and lower boundaries.
The RangeValidator control allows you to check whether a user's entry is between a specified upper and a specified lower boundary. You can check ranges within pairs of numbers, alphabetic characters, and dates. Boundaries are expressed as constants.