Bug in CompareValidator ?

  • Thread starter Thread starter Radu
  • Start date Start date
R

Radu

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Test.aspx.vb"
Inherits="Test" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://
www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:TextBox
ID="PINTextBoxAdd"
MaxLength="6"
AutoCompleteType="disabled"
Runat="Server">
</asp:TextBox>
<asp:RegularExpressionValidator
id="regexPINAdd"
ControlToValidate="PINTextBoxAdd"
Display="Dynamic"
ValidationExpression="^\d{6}$"
Text="*"
ErrorMessage="The Employee's PIN is not correct !"
runat="server">
</asp:RegularExpressionValidator>
<asp:CompareValidator
id="comparePINAdd"
ControlToValidate ="PINTextBoxAdd"
ValueToCompare="100000"
Operator="GreaterThan"
Display="Dynamic"
Text="*"
ErrorMessage="The Employee's PIN has to be greater than
100,000 !"
runat="server">
</asp:CompareValidator>
<asp:ValidationSummary
id="validSummaryAdd"
ShowSummary="false"
ShowMessageBox="true"
runat="server"/>
<asp:Button ID="Button1" Text="Submit" runat="server" />
</div>
</form>
</body>
</html>

Try with 0. You get BOTH messages.
Try with 1. You get BOTH messages.
Try with >1. You get only "The Employee's PIN is not correct !" The
compare validator does not trigger anymore. Is this a normal
behaviour ?

Thank you.
Alex.
 
Radu wrote on 23-12-2008 :
<asp:CompareValidator
id="comparePINAdd"
ControlToValidate ="PINTextBoxAdd"
ValueToCompare="100000"
Operator="GreaterThan"
Display="Dynamic"
Text="*"
ErrorMessage="The Employee's PIN has to be greater than
100,000 !"
runat="server">
</asp:CompareValidator>
Try with 0. You get BOTH messages.
Try with 1. You get BOTH messages.
Try with >1. You get only "The Employee's PIN is not correct !" The
compare validator does not trigger anymore. Is this a normal
behaviour ?

Thank you.
Alex.

Add a property: Type="Integer"
The default is "String" and that gives different results, as you found
out..

Hans Kesting
 
Back
Top