Expand my Community achievements bar.

Validate failed error - help wih script

Avatar

Former Community Member
Hi,



First off, i don't know much javascript basically none and i am new to formcalc so please bear with me.



So here is what i am trying to do, i have a table on a form where a user can fill in the cells if they want to change a contribution amount for their investment options. The column of the table must equal 100 otherwise they haven't specified the correct values and the contributions are wrong.



So far i have added script on each cell to validate if the number is between 0 - 100



(this.rawValue >= 0 && this.rawValue < 101);



this is working ok, where it is going wrong is here:



the last cell in the column is a total field and what i want it to do is:



a) add up the total, again this is working



SUM(Row1[*].exist + Row2[*].exist)



b) check to see if the total is equal to 100, if it is not change the font color to red, or if it is equal to 100 the font color is black. What i have in the script is:

if (Row3[*].total ne 100) then

total.fontColor = "255,0,0"

elseif (Row3[*].total eq 100) then

total.fontColor = "0,0,0"

endif

this works if the total is not 100 the font is red, but where it is going wrong is if it does equal 100, i am getting an error message saying "total validate failed" but the strange thing is the total is showing 100 and in black.



What am i doing wrong? Is there a better way of doing this in Javascript?



I am not using the finished form, i am just testing that is why the field names are basic as well.



Thanks in advance
0 Replies