This is a migrated thread and some comments may be shown as answers.

compare value of two radnumeric with comparevalidator

1 Answer 115 Views
Input
This is a migrated thread and some comments may be shown as answers.
Ragil
Top achievements
Rank 1
Ragil asked on 21 Jan 2020, 08:38 AM

Dear All,

 

i am trying to create form as amount inputter, using RadNumericText and CompareValidator (to compare min max value between RadNumeric) through code behind. CompareValidator work perfectly where value of RadNumeric doesn't contain digit behind commas (attached images : data no 1), but, when i'm inputted value with commas, it's doesn't working as expected, as shown in the attached images.

No         City               Min                     Max

1            Aceh             $ 100.001,00      $ 100.000,00

                                                               *Amount min cannot be greater than amount max

2.           Yogya           $ 100.000,00      $ 100.000,00

 

3.           Banten         $ 100.000,88      $ 100.000,99

                                                             *Amount min cannot be greater than amount max

 

From data above, no 1, CompareValidator working perfectly, but not for data no 3, where value has any digit behind commas. Any advice how to compare min max value with commas at data no 3 ?

 

Regard,

 

Ragil

 

protected RadNumericTextBox mytextbox;
 
public void InstantiateIn(System.Web.UI.Control container)
{
    mytextbox = new RadNumericTextBox();
    mytextbox.AutoPostBack = false;
    mytextbox.ID = rankName + typeName + "MyTextBox";
    mytextbox.NumberFormat.DecimalDigits = 2;
    mytextbox.NumberFormat.GroupSeparator = ".";
    mytextbox.NumberFormat.DecimalSeparator = ",";
    mytextbox.Type = NumericType.Currency;
    //mytextbox.DataType = "System.Decimal";
 
    reqValid = new RequiredFieldValidator();
    reqValid.ForeColor = System.Drawing.Color.Red;
    reqValid.ErrorMessage = "* Required field";
    reqValid.CssClass = "has-error";
    reqValid.ControlToValidate = rankName + typeName + "MyTextBox";
    reqValid.Display = ValidatorDisplay.Dynamic;
 
    if (typeName == "Max")
    {
        compValid = new CompareValidator();
        compValid.ForeColor = System.Drawing.Color.Red;
        compValid.ErrorMessage = "* Amount Min can not be greater than Amount Max";
        compValid.CssClass = "has-error";
        compValid.Display = ValidatorDisplay.Dynamic;
 
        compValid.ControlToValidate = rankName + "Max" + "MyTextBox";
        compValid.ControlToCompare = rankName + "Min" + "MyTextBox";
        compValid.Operator = ValidationCompareOperator.GreaterThanEqual;
        compValid.Type = ValidationDataType.Currency;
        compValid.ValidationGroup = "ValidateAmount";
 
    }
 
    container.Controls.Add(mytextbox);
    container.Controls.Add(reqValid);
 
    if (typeName == "Max")
    {
        container.Controls.Add(compValid);
    }
}

1 Answer, 1 is accepted

Sort by
0
Accepted
Attila Antal
Telerik team
answered on 23 Jan 2020, 04:28 PM

Hi Ragil,

This is a known issue if setting the Decimal separator using a coma as this changes the Culture format to a different one and the Compare validator does not compare the values of the same culture, see RadNumericTextBox and CompareValidator.

Kind regards,
Attila Antal
Progress Telerik

Get quickly onboarded and successful with UI for ASP.NET AJAX with the Virtual Classroom technical trainings, available to all active customers. Learn More.
Tags
Input
Asked by
Ragil
Top achievements
Rank 1
Answers by
Attila Antal
Telerik team
Share this question
or