Validation on 2 different number fields

Hi @mnikitina / @Nikita_Kurguzov ,

I have two number fields, One allowing a - symbol and second not allowing - symbol values


I want to validate if the amounts are the same, if the top amount has a negative value of -20 and the bottom has a value of 20 it should come back as true, the validation should only be false if the values differ eg, -30 as top and 20 as bottom. How do I get my validation to ignore the negative - symbol and only look at the number values?

My code works at the moment if both values are not negative.

My code at the moment:


fd.spRendered(function() {  
    fd.validators.push({
            name: 'Totals fieldsValidation',
            error: "Difference breakdown does not match Money Market POS Difference Amount",
            validate: function(value) {
               if (fd.field('Difference_x003a_').value === fd.field('DiffTotal').value) {
                            return true;
                        }
                return false;
             }
    });
})

Dear @Dina_Louw,
Please, try the following:

fd.spRendered(function() {  
    fd.validators.push({
            name: 'Totals fieldsValidation',
            error: "Difference breakdown does not match Money Market POS Difference Amount",
            validate: function(value) {
               if (Math.abs(fd.field('Difference_x003a_').value)  == Math.abs(fd.field('DiffTotal').value)) {
                            return true;
                        }
                return false;
             }
    });
})
1 Like

Thank you @Nikita_Kurguzov - that worked perfect.