Comparing 2 currency fields

sikoras
Kilo Contributor


I have tried several ways to compare 2 currency fields and can't get it to work - this is what I currently have in place within a client script:

 

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
    if (isLoading || newValue == '') {
          return false;
    }

    if (parseInt(u_total_lc_cost.value) != (parseInt(u_total_cost.value) ))
    {alert('ROM total and Lifecycle totals must equal'); }
    return false;
}

1 REPLY 1

PeterWiles
Kilo Sage

Hi there,



A few things are wrong there. The script will not know what "u_total_lc_cost is. You need to get the value.



var lc = g_form.getValue("u_total_lc_cost");



You need to do the same with the other variable as well.   Once done, test that. If that still doesn't work, you need to use "parseFloat" and not "paeseInt" since currency is not an integer



If it's still not working, use alert() statement with the two values in to see what the values are showing as once converted to floats.



Pete