Remove Comments
default.aspx
<%--<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Validation Server Controls</title>
<script type="text/javascript">
function validatenumber(oSrc,args)
{
var str = document.getElementById('<%=TextBox5.ClientID%>').value;
alert(str.length);
args.IsValid = (args.Value % 6 == 0)
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<h3>RequiredFieldValidator checks to see that textbox has data before you click submit button.In essence,it enforces Mandatory field rule <br/></h3>
<h3>When Validation fails, "Required!" will be displayed</h3>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" Text="Required!" runat="server" ValidationGroup="Submit" ErrorMessage="Required!" ControlToValidate="TextBox1">
</asp:RequiredFieldValidator>
<asp:Button ID="Button1" runat="server" ValidationGroup="Submit" Text="Submit"/>
</div>
<div>
<h3>CompareFieldValidator,as name says, compares two form element's values against each other.It enforces "Same-As" rule.</h3>
<table>
<tr>
<td>
<asp:Label ID="Label1" runat="server" Text="Enter Password"></asp:Label>
</td>
<td>
<asp:TextBox ID="TextBox2" TextMode="Password" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td>
<asp:Label ID="Label2" runat="server" Text="Confirm Password"></asp:Label>
</td>
<td>
<asp:TextBox ID="TextBox3" TextMode="password" runat="server"></asp:TextBox>
</td>
<td>
<asp:Button ID="Button2" runat="server" Text="Login"/>
</td>
</tr>
</table>
<asp:CompareValidator ID="CompareValidator1" runat="server" ErrorMessage="Passwords don't match!" ControlToValidate="TextBox3"
ControlToCompare="textbox2" ></asp:CompareValidator>
</div>
<div>
<h3>RangeValidators enforces that values you enter fall under specified range.It enforces "Between-the" rule.</h3>
<asp:RangeValidator ID="RangeValidator1" runat="server" ErrorMessage="Value must be between 20 and 30" ControlToValidate="RangeTextbox"
Type="Integer" MinimumValue="20" MaximumValue="30" Text="*">
</asp:RangeValidator>
<asp:TextBox ID="RangeTextbox" runat="server"></asp:TextBox>
<asp:Button ID="CheckRange" runat="server" Text="CheckRange" />
</div>
<div>
<h3>RegularExpressionValidator checks for a specific pattern.It enforces "As-is" rule.</h3>
<asp:TextBox ID="TextBox4" runat="server"></asp:TextBox>
<asp:RegularExpressionValidator ID="RegularExpressionValidator1" Text="*" ControlToValidate="Textbox4" runat="server"
ErrorMessage="You must enter an email address" ValidationGroup="CheckMail" ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"></asp:RegularExpressionValidator>
<asp:Button ID="Button3" runat="server" ValidationGroup="CheckMail" Text="CheckMail"/>
</div>
<div>
<h3>CustomValidator control to implement custom tailored Validations. It enforces "My-Own" rule.</h3>
<asp:CustomValidator ID="CustomValidator1" runat="server"
ControlToValidate="textbox5" ClientValidationFunction="validatenumber"
ErrorMessage="Number is not divisible by 6"></asp:CustomValidator>
<asp:TextBox ID="TextBox5" runat="server"></asp:TextBox>
<asp:Button ID="Button4" runat="server" Text="Divisible" />
</div>
<asp:ValidationSummary ID="ValidationSummary1" DisplayMode="BulletList" HeaderText="You received following errors" runat="server" />
</form>
</body>
</html>
--%>
default.aspx
<%--<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Validation Server Controls</title>
<script type="text/javascript">
function validatenumber(oSrc,args)
{
var str = document.getElementById('<%=TextBox5.ClientID%>').value;
alert(str.length);
args.IsValid = (args.Value % 6 == 0)
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<h3>RequiredFieldValidator checks to see that textbox has data before you click submit button.In essence,it enforces Mandatory field rule <br/></h3>
<h3>When Validation fails, "Required!" will be displayed</h3>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" Text="Required!" runat="server" ValidationGroup="Submit" ErrorMessage="Required!" ControlToValidate="TextBox1">
</asp:RequiredFieldValidator>
<asp:Button ID="Button1" runat="server" ValidationGroup="Submit" Text="Submit"/>
</div>
<div>
<h3>CompareFieldValidator,as name says, compares two form element's values against each other.It enforces "Same-As" rule.</h3>
<table>
<tr>
<td>
<asp:Label ID="Label1" runat="server" Text="Enter Password"></asp:Label>
</td>
<td>
<asp:TextBox ID="TextBox2" TextMode="Password" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td>
<asp:Label ID="Label2" runat="server" Text="Confirm Password"></asp:Label>
</td>
<td>
<asp:TextBox ID="TextBox3" TextMode="password" runat="server"></asp:TextBox>
</td>
<td>
<asp:Button ID="Button2" runat="server" Text="Login"/>
</td>
</tr>
</table>
<asp:CompareValidator ID="CompareValidator1" runat="server" ErrorMessage="Passwords don't match!" ControlToValidate="TextBox3"
ControlToCompare="textbox2" ></asp:CompareValidator>
</div>
<div>
<h3>RangeValidators enforces that values you enter fall under specified range.It enforces "Between-the" rule.</h3>
<asp:RangeValidator ID="RangeValidator1" runat="server" ErrorMessage="Value must be between 20 and 30" ControlToValidate="RangeTextbox"
Type="Integer" MinimumValue="20" MaximumValue="30" Text="*">
</asp:RangeValidator>
<asp:TextBox ID="RangeTextbox" runat="server"></asp:TextBox>
<asp:Button ID="CheckRange" runat="server" Text="CheckRange" />
</div>
<div>
<h3>RegularExpressionValidator checks for a specific pattern.It enforces "As-is" rule.</h3>
<asp:TextBox ID="TextBox4" runat="server"></asp:TextBox>
<asp:RegularExpressionValidator ID="RegularExpressionValidator1" Text="*" ControlToValidate="Textbox4" runat="server"
ErrorMessage="You must enter an email address" ValidationGroup="CheckMail" ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"></asp:RegularExpressionValidator>
<asp:Button ID="Button3" runat="server" ValidationGroup="CheckMail" Text="CheckMail"/>
</div>
<div>
<h3>CustomValidator control to implement custom tailored Validations. It enforces "My-Own" rule.</h3>
<asp:CustomValidator ID="CustomValidator1" runat="server"
ControlToValidate="textbox5" ClientValidationFunction="validatenumber"
ErrorMessage="Number is not divisible by 6"></asp:CustomValidator>
<asp:TextBox ID="TextBox5" runat="server"></asp:TextBox>
<asp:Button ID="Button4" runat="server" Text="Divisible" />
</div>
<asp:ValidationSummary ID="ValidationSummary1" DisplayMode="BulletList" HeaderText="You received following errors" runat="server" />
</form>
</body>
</html>
--%>
No comments:
Post a Comment