I think I may have edited my response, above, after you checked it, so you may have missed what I think is the most likely problem.
I set my input field to accept numbers. If you set yours to accept text, you may be entering non-numeric characters (like commas or a dollar sign). In that case, the code would fail.