That code will work for a text field, but not a numeric field. For a text field, the rawValue is a JavaScript String object, which has a length property. That is unless the field is empty, in which case it contains null, which you should test for in your code. A numeric field returns an integer or a float, depending on how you've got it configured.