This content has been marked as final. Show 6 replies
the text property of a textfield is always a string. if you want to compare that string to a number, convert it (using the Number() function is usually adequate).
so do i write that out as
if (Number(KHP) == KHPanswer)
if (Number(KHP.text) == KHPanswer)
because both of those still aren't working with 0.09952
ok so i've changed it to
var KHPanswer = Number("0.09952");
and that seems to work, so does that mean I need to be ultra careful with how I define numbers in text fields? Because that seemed awefully touchy (ie not accepting 0.09952 but accepting 0.09954!!!)
the best way to check for equality of numbers, if to check if their diffence is zero (after converting any strings to numbers). you can also compare strings as you've done in your last message.
i'll try to be a bit more careful next time with my coding