I'm trying to validate three fields client side. I am using the event "on".
The sum of field1 and field2 must be equal to field3. All must be input by keyboard.
to achieve this I created this function:
//Validate client side total field: Population
var ctrlTotalPopulation = Runner.getControl(pageid, "totalPopulation");
var ctrlMen = Runner.getControl(pageid, "men");
var ctrlWomen = Runner.getControl(pageid, "women");
ctrlTotalPopulation.on('change', VerifiedTotal(ctrlTotalPopulation.getValue(), ctrlMen.getValue(), ctrlWomen.getValue()));
function VerifiedTotal(total, num1, num2) {
var alerta = eval(parseInt(num1) + parseInt(num2));
var num2 = parseInt(num2);
var total = parseInt(total);
if(total != eval(parseInt(num1) + parseInt(num2))){
alert('This amount not match');
//alert(num3);
return false;
}
else {
return true;
}
}
but the event only is triggered when loading the page.
Any idea why?
Thanks for any help!!!