
Michal Siudyka
Top achievements
Rank 2
Michal Siudyka
asked on 17 Feb 2010, 09:45 AM
Hi,
I try to validate two RadNumericTextBox control by CompareValidator:
<telerik:RadNumericTextBox id="NumberMinValueTextBox" runat="server" /> |
<telerik:RadNumericTextBox id="NumberMaxValueTextBox" runat="server" /> |
<asp:CompareValidator ID="NumberMinMaxValidator" runat="server" ErrorMessage="The max value couldn't be less than the min value." Operator="GreaterThanEqual" ControlToCompare="NumberMinValueTextBox" ControlToValidate="NumberMaxValueTextBox" ValidationGroup="NumberField" Display="Dynamic" /> |
It works ok only, when the compared values in the both min and max control contain the same number of digits.
(i.e min = 1, max = 9 or min = 10, max = 25 etc.)
But when I enter e.g. '12' to min control and '102' validation failed. It looks that the max value is trimmed from '102' to '10' then 12 > 10 and validatio failed.
What am I doing wrong? Thanks in advance.
10 Answers, 1 is accepted
0

Shinu
Top achievements
Rank 2
answered on 17 Feb 2010, 10:28 AM
Hello Michal,
I also experienced same issue when tried your code. I achieved same functionality by using CustomValidator instead of CompareValidator. Here is the code that I tried. Hope this helps.
ASPX:
JavaScript:
-Shinu.
I also experienced same issue when tried your code. I achieved same functionality by using CustomValidator instead of CompareValidator. Here is the code that I tried. Hope this helps.
ASPX:
<telerik:RadNumericTextBox ID="NumberMinValueTextBox" runat="server" /> |
<telerik:RadNumericTextBox ID="NumberMaxValueTextBox" runat="server" /> |
<asp:CustomValidator ID="CustomValidator1" ControlToValidate="NumberMaxValueTextBox" |
runat="server" ClientValidationFunction="ClientValidate" ErrorMessage="The max value couldn't be less than the min value."> |
</asp:CustomValidator> |
JavaScript:
<script type="text/javascript"> |
function ClientValidate(source, arguments) { |
var min = $find('<%= NumberMinValueTextBox.ClientID %>'); |
var max = $find('<%= NumberMaxValueTextBox.ClientID %>'); |
if (min.get_value() > max.get_value()) { |
arguments.IsValid = false; |
} |
} |
</script> |
-Shinu.
0

Michal Siudyka
Top achievements
Rank 2
answered on 17 Feb 2010, 10:53 AM
Thank you, of course your code solved my problem and I know that I can use customvalidator.
But as you wrote above there is needed some javascript code and also some function on server side for validation when the javascript support is disabled. That's why I wanted to use a comparevalidator :)
Is there some bug in CompareValidator control or RadNumericTextBox ?
But as you wrote above there is needed some javascript code and also some function on server side for validation when the javascript support is disabled. That's why I wanted to use a comparevalidator :)
Is there some bug in CompareValidator control or RadNumericTextBox ?
0
Accepted
Hello,
The CompareValidator does not work as expected, because by default it compares strings:
http://msdn.microsoft.com/en-us/library/system.web.ui.mobilecontrols.comparevalidator.type.aspx
Please set Type="Double" and there will be no need to use a custom validator.
Regards,
Dimo
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
The CompareValidator does not work as expected, because by default it compares strings:
http://msdn.microsoft.com/en-us/library/system.web.ui.mobilecontrols.comparevalidator.type.aspx
Please set Type="Double" and there will be no need to use a custom validator.
Regards,
Dimo
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0

Michal Siudyka
Top achievements
Rank 2
answered on 01 Jul 2010, 09:08 AM
Hi,
Now, I have a problem when the RadNumericTextBox control has set the comma (,) decimal separator and the CompareValidator does not work as expected. Any ideas?
Regards,
0
Hi Michal,
I cannot observe a problem with CompareValidator and RadNumericTextBoxes with comma as a decimal separator. Can you provide a simple test page?
Greetings,
Dimo
the Telerik team
I cannot observe a problem with CompareValidator and RadNumericTextBoxes with comma as a decimal separator. Can you provide a simple test page?
Greetings,
Dimo
the Telerik team
Do you want to have your say when we set our development plans?
Do you want to know when a feature you care about is added or when a bug fixed?
Explore the
Telerik Public Issue Tracking
system and vote to affect the priority of the items
0

Michal Siudyka
Top achievements
Rank 2
answered on 05 Jul 2010, 10:58 PM
Hi,
Here is sample:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" Culture="auto" UICulture="auto" %> |
<%@ Register assembly="Telerik.Web.UI, Version=2010.1.519.20, Culture=neutral, PublicKeyToken=121fae78165ba3d4" namespace="Telerik.Web.UI" tagprefix="telerik" %> |
<!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></title> |
</head> |
<body> |
<form id="form1" runat="server"> |
<div> |
<asp:ScriptManager ID="ScriptManager1" runat="server"> |
</asp:ScriptManager> |
<telerik:RadNumericTextBox ID="RadNumericTextBox2" Runat="server"> |
<NumberFormat DecimalSeparator="," DecimalDigits="2" /> |
</telerik:RadNumericTextBox> |
<telerik:RadNumericTextBox ID="RadNumericTextBox1" Runat="server"> |
<NumberFormat DecimalSeparator="," DecimalDigits="2" /> |
</telerik:RadNumericTextBox> |
<asp:CompareValidator ID="CompareValidator1" runat="server" ControlToValidate="RadNumericTextBox2" ControlToCompare="RadNumericTextBox1" Operator="LessThan" Type="Double" |
ErrorMessage="CompareValidator"></asp:CompareValidator> |
</div> |
</form> |
</body> |
</html> |
and codebehind
public partial class _Default : System.Web.UI.Page |
{ |
protected void Page_Load(object sender, EventArgs e) |
{ |
System.Globalization.CultureInfo info = System.Globalization.CultureInfo.CreateSpecificCulture("en"); |
System.Threading.Thread.CurrentThread.CurrentUICulture = info; |
System.Threading.Thread.CurrentThread.CurrentCulture = info; |
} |
} |
Notice that a user's culture is set up to english (bescause all of the resource have to be displayed in English language), but there are some customizable fields that could have a comma as separator.
0
Hi Michal,
The provided sample page works as expected on my side. I tested in Firefox and Internet Explorer. See the attached screeshot.
All the best,
Dimo
the Telerik team
The provided sample page works as expected on my side. I tested in Firefox and Internet Explorer. See the attached screeshot.
<%@ Page Language="C#" %>
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<
script
runat
=
"server"
>
protected void Page_Load(object sender, EventArgs e)
{
System.Globalization.CultureInfo info = System.Globalization.CultureInfo.CreateSpecificCulture("en");
System.Threading.Thread.CurrentThread.CurrentUICulture = info;
System.Threading.Thread.CurrentThread.CurrentCulture = info;
}
</
script
>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
<
html
xmlns
=
"http://www.w3.org/1999/xhtml"
>
<
head
runat
=
"server"
>
<
meta
http-equiv
=
"content-type"
content
=
"text/html;charset=utf-8"
/>
<
title
>RadControls</
title
>
</
head
>
<
body
>
<
form
id
=
"form1"
runat
=
"server"
>
<
asp:ScriptManager
ID
=
"ScriptManager1"
runat
=
"server"
/>
<
telerik:RadNumericTextBox
ID
=
"RadNumericTextBox2"
Runat
=
"server"
>
<
NumberFormat
DecimalSeparator
=
","
DecimalDigits
=
"2"
/>
</
telerik:RadNumericTextBox
>
<
telerik:RadNumericTextBox
ID
=
"RadNumericTextBox1"
Runat
=
"server"
>
<
NumberFormat
DecimalSeparator
=
","
DecimalDigits
=
"2"
/>
</
telerik:RadNumericTextBox
>
<
asp:CompareValidator
ID
=
"CompareValidator1"
runat
=
"server"
ControlToValidate
=
"RadNumericTextBox2"
ControlToCompare
=
"RadNumericTextBox1"
Operator
=
"LessThan"
Type
=
"Double"
ErrorMessage
=
"CompareValidator"
></
asp:CompareValidator
>
<
br
/><
br
/><
br
/>
<
telerik:RadNumericTextBox
ID
=
"RadNumericTextBox3"
Runat
=
"server"
>
<
NumberFormat
DecimalSeparator
=
","
DecimalDigits
=
"2"
/>
</
telerik:RadNumericTextBox
>
<
telerik:RadNumericTextBox
ID
=
"RadNumericTextBox4"
Runat
=
"server"
>
<
NumberFormat
DecimalSeparator
=
","
DecimalDigits
=
"2"
/>
</
telerik:RadNumericTextBox
>
<
asp:CompareValidator
ID
=
"CompareValidator2"
runat
=
"server"
ControlToValidate
=
"RadNumericTextBox3"
ControlToCompare
=
"RadNumericTextBox4"
Operator
=
"LessThan"
Type
=
"Double"
ErrorMessage
=
"CompareValidator"
></
asp:CompareValidator
>
</
form
>
</
body
>
</
html
>
All the best,
Dimo
the Telerik team
Do you want to have your say when we set our development plans?
Do you want to know when a feature you care about is added or when a bug fixed?
Explore the
Telerik Public Issue Tracking
system and vote to affect the priority of the items
0

Michal Siudyka
Top achievements
Rank 2
answered on 06 Jul 2010, 09:37 AM
Ok, but enter some digits different then zero after separator and add
Culture="auto" UICulture="auto" |
in the <%@ Page Language="C#" %> declaration.
0
Accepted
Hello Michal,
Thanks, now I reproduced the problem. However, the same behavior is exhibited with standard asp:TextBoxes if you use comma as a decimal separator. So the problem is the culture and separator inconsistency and the way the validator interprets those. Please consider changing the culture/separator settings.
Best wishes,
Dimo
the Telerik team
Thanks, now I reproduced the problem. However, the same behavior is exhibited with standard asp:TextBoxes if you use comma as a decimal separator. So the problem is the culture and separator inconsistency and the way the validator interprets those. Please consider changing the culture/separator settings.
Best wishes,
Dimo
the Telerik team
Do you want to have your say when we set our development plans?
Do you want to know when a feature you care about is added or when a bug fixed?
Explore the
Telerik Public Issue Tracking
system and vote to affect the priority of the items
0

Michal Siudyka
Top achievements
Rank 2
answered on 09 Jul 2010, 08:36 AM
Hi Dimo,
Thanks, so I have to use a custom validator.
Regards,
MichaĆ
Thanks, so I have to use a custom validator.
Regards,
MichaĆ