cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

field validation for numeric values

Former Member
0 Likes
154

Hi,

There is a cutomization need for field validation on numeric values..

I have a script with me for the field validation butnot able to see the desired out put...

if(hasValue(fieldValue ))

if(fieldValue > 50)

throw doc.createApplicationException(field.getAttributeId(),"should be in bet 50");

The target is ESTIMATED under RFx..

When i am entering 70 it is not throwing any error.. ideally i should throw...

Can anyone suggest any inputs..

Thanks in advance

Regards

Jagmohan

Accepted Solutions (0)

Answers (1)

Answers (1)

martin_schffler
Participant
0 Likes

The fieldValue is not an int but an object of type BigDecimal so you have to use the compareTo() methods in that object to compare its value.

So your code would look like this:


java.math.BigDecimal limit = new java.math.BigDecimal(50.0);
if(hasValue(fieldValue))
    if(limit.compareTo(fieldValue) == -1)
      throw exception..

Former Member
0 Likes

Dear Martin,

Thanks for the quick reply... I tried with the same structure, But still not able to get the desired reult (when passing a value greater then the limit) i.e not getting the exception...

here is another code which i tried after yours

import java.math.BigDecimal;

BigDecimal decimalB = new BigDecimal("50.0");

if(hasValue(fieldValue))

if(decimalB.compareTo(fieldValue) == -1)

throw doc.createApplicationException(field.getAttributeId(),"should be in bet 50");

Appriciate your input on this or any other suggestion...

BR

Jaggs

Edited by: JPadhy on May 21, 2010 7:19 AM

Edited by: JPadhy on May 21, 2010 7:20 AM